dglazkov@chromium.org | e875a8e | 2009-03-05 17:14:07 +0000 | [diff] [blame] | 1 | /* |
| 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.org | e875a8e | 2009-03-05 17:14:07 +0000 | [diff] [blame] | 32 | |
abarth@webkit.org | 1d28bb5 | 2011-09-16 05:41:19 +0000 | [diff] [blame] | 33 | #if ENABLE(SQL_DATABASE) && ENABLE(INSPECTOR) |
yurys@chromium.org | 83110c8 | 2012-03-15 16:44:09 +0000 | [diff] [blame] | 34 | |
| 35 | #include "InspectorDatabaseResource.h" |
| 36 | |
dglazkov@chromium.org | e875a8e | 2009-03-05 17:14:07 +0000 | [diff] [blame] | 37 | #include "Database.h" |
joepeck@webkit.org | 8be4912 | 2013-12-13 21:07:13 +0000 | [diff] [blame] | 38 | #include "InspectorWebFrontendDispatchers.h" |
joepeck@webkit.org | a319844 | 2013-12-11 22:40:23 +0000 | [diff] [blame] | 39 | #include <inspector/InspectorValues.h> |
| 40 | |
| 41 | using namespace Inspector; |
dglazkov@chromium.org | ba483d7 | 2009-05-19 16:58:01 +0000 | [diff] [blame] | 42 | |
dglazkov@chromium.org | e875a8e | 2009-03-05 17:14:07 +0000 | [diff] [blame] | 43 | namespace WebCore { |
| 44 | |
pfeldman@chromium.org | 7e420b5 | 2011-03-21 07:54:32 +0000 | [diff] [blame] | 45 | static int nextUnusedId = 1; |
pfeldman@chromium.org | 5f25b5d | 2009-10-07 09:32:06 +0000 | [diff] [blame] | 46 | |
yurys@chromium.org | 7aae7d2 | 2010-08-04 14:43:22 +0000 | [diff] [blame] | 47 | PassRefPtr<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 | |
| 52 | InspectorDatabaseResource::InspectorDatabaseResource(PassRefPtr<Database> database, const String& domain, const String& name, const String& version) |
dglazkov@chromium.org | e144f89 | 2009-03-13 21:31:02 +0000 | [diff] [blame] | 53 | : m_database(database) |
yurys@chromium.org | fff9d7f | 2012-04-03 12:07:53 +0000 | [diff] [blame] | 54 | , m_id(String::number(nextUnusedId++)) |
dglazkov@chromium.org | e144f89 | 2009-03-13 21:31:02 +0000 | [diff] [blame] | 55 | , m_domain(domain) |
| 56 | , m_name(name) |
| 57 | , m_version(version) |
| 58 | { |
| 59 | } |
dglazkov@chromium.org | e875a8e | 2009-03-05 17:14:07 +0000 | [diff] [blame] | 60 | |
joepeck@webkit.org | 20fd448 | 2013-11-13 22:58:16 +0000 | [diff] [blame] | 61 | void InspectorDatabaseResource::bind(InspectorDatabaseFrontendDispatcher* databaseFrontendDispatcher) |
dglazkov@chromium.org | e144f89 | 2009-03-13 21:31:02 +0000 | [diff] [blame] | 62 | { |
joepeck@webkit.org | a319844 | 2013-12-11 22:40:23 +0000 | [diff] [blame] | 63 | RefPtr<Inspector::TypeBuilder::Database::Database> jsonObject = Inspector::TypeBuilder::Database::Database::create() |
yurys@chromium.org | b2a04bc | 2012-04-04 09:36:28 +0000 | [diff] [blame] | 64 | .setId(m_id) |
| 65 | .setDomain(m_domain) |
| 66 | .setName(m_name) |
| 67 | .setVersion(m_version); |
joepeck@webkit.org | 20fd448 | 2013-11-13 22:58:16 +0000 | [diff] [blame] | 68 | databaseFrontendDispatcher->addDatabase(jsonObject); |
dglazkov@chromium.org | e144f89 | 2009-03-13 21:31:02 +0000 | [diff] [blame] | 69 | } |
dglazkov@chromium.org | e875a8e | 2009-03-05 17:14:07 +0000 | [diff] [blame] | 70 | |
| 71 | } // namespace WebCore |
| 72 | |
abarth@webkit.org | 1d28bb5 | 2011-09-16 05:41:19 +0000 | [diff] [blame] | 73 | #endif // ENABLE(SQL_DATABASE) && ENABLE(INSPECTOR) |