blob: 1badbdf3f1e41b53c2338025ae00f842c8c222e5 [file] [log] [blame]
dglazkov@chromium.orge875a8e2009-03-05 17:14:07 +00001/*
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com>
4 * Copyright (C) 2009 Google Inc. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of
16 * its contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
20 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#include "config.h"
dglazkov@chromium.orge875a8e2009-03-05 17:14:07 +000032
abarth@webkit.org1d28bb52011-09-16 05:41:19 +000033#if ENABLE(SQL_DATABASE) && ENABLE(INSPECTOR)
yurys@chromium.org83110c82012-03-15 16:44:09 +000034
35#include "InspectorDatabaseResource.h"
36
dglazkov@chromium.orge875a8e2009-03-05 17:14:07 +000037#include "Database.h"
joepeck@webkit.org8be49122013-12-13 21:07:13 +000038#include "InspectorWebFrontendDispatchers.h"
joepeck@webkit.orga3198442013-12-11 22:40:23 +000039#include <inspector/InspectorValues.h>
40
41using namespace Inspector;
dglazkov@chromium.orgba483d72009-05-19 16:58:01 +000042
dglazkov@chromium.orge875a8e2009-03-05 17:14:07 +000043namespace WebCore {
44
pfeldman@chromium.org7e420b52011-03-21 07:54:32 +000045static int nextUnusedId = 1;
pfeldman@chromium.org5f25b5d2009-10-07 09:32:06 +000046
yurys@chromium.org7aae7d22010-08-04 14:43:22 +000047PassRefPtr<InspectorDatabaseResource> InspectorDatabaseResource::create(PassRefPtr<Database> database, const String& domain, const String& name, const String& version)
48{
49 return adoptRef(new InspectorDatabaseResource(database, domain, name, version));
50}
51
52InspectorDatabaseResource::InspectorDatabaseResource(PassRefPtr<Database> database, const String& domain, const String& name, const String& version)
dglazkov@chromium.orge144f892009-03-13 21:31:02 +000053 : m_database(database)
yurys@chromium.orgfff9d7f2012-04-03 12:07:53 +000054 , m_id(String::number(nextUnusedId++))
dglazkov@chromium.orge144f892009-03-13 21:31:02 +000055 , m_domain(domain)
56 , m_name(name)
57 , m_version(version)
58{
59}
dglazkov@chromium.orge875a8e2009-03-05 17:14:07 +000060
joepeck@webkit.org20fd4482013-11-13 22:58:16 +000061void InspectorDatabaseResource::bind(InspectorDatabaseFrontendDispatcher* databaseFrontendDispatcher)
dglazkov@chromium.orge144f892009-03-13 21:31:02 +000062{
joepeck@webkit.orga3198442013-12-11 22:40:23 +000063 RefPtr<Inspector::TypeBuilder::Database::Database> jsonObject = Inspector::TypeBuilder::Database::Database::create()
yurys@chromium.orgb2a04bc2012-04-04 09:36:28 +000064 .setId(m_id)
65 .setDomain(m_domain)
66 .setName(m_name)
67 .setVersion(m_version);
joepeck@webkit.org20fd4482013-11-13 22:58:16 +000068 databaseFrontendDispatcher->addDatabase(jsonObject);
dglazkov@chromium.orge144f892009-03-13 21:31:02 +000069}
dglazkov@chromium.orge875a8e2009-03-05 17:14:07 +000070
71} // namespace WebCore
72
abarth@webkit.org1d28bb52011-09-16 05:41:19 +000073#endif // ENABLE(SQL_DATABASE) && ENABLE(INSPECTOR)