Changeset 65072 in webkit


Ignore:
Timestamp:
Aug 10, 2010 9:06:38 AM (14 years ago)
Author:
pfeldman@chromium.org
Message:

2010-08-10 Pavel Feldman <pfeldman@chromium.org>

Reviewed by Yury Semikhatsky.

Web Inspector: move database processing to native layer.

https://bugs.webkit.org/show_bug.cgi?id=43788

  • English.lproj/localizedStrings.js:
  • WebCore.gypi:
  • bindings/js/JSInjectedScriptHostCustom.cpp:
  • bindings/v8/custom/V8InjectedScriptHostCustom.cpp:
  • inspector/CodeGeneratorInspector.pm:
  • inspector/InjectedScript.cpp: (WebCore::InjectedScript::dispatch):
  • inspector/InjectedScript.h:
  • inspector/InjectedScriptHost.cpp:
  • inspector/InjectedScriptHost.h:
  • inspector/InjectedScriptHost.idl:
  • inspector/Inspector.idl:
  • inspector/InspectorBackend.cpp: (WebCore::InspectorBackend::dispatchOnInjectedScript): (WebCore::InspectorBackend::executeSQL):
  • inspector/InspectorBackend.h:
  • inspector/InspectorController.cpp: (WebCore::InspectorController::connectFrontend): (WebCore::InspectorController::releaseFrontendLifetimeAgents):
  • inspector/InspectorController.h:
  • inspector/InspectorDebuggerAgent.h:
  • inspector/InspectorStorageAgent.cpp: Added. (WebCore::): (WebCore::InspectorStorageAgent::InspectorStorageAgent): (WebCore::InspectorStorageAgent::~InspectorStorageAgent): (WebCore::InspectorStorageAgent::executeSQL): (WebCore::InspectorStorageAgent::clearFrontend):
  • inspector/InspectorStorageAgent.h: Added. (WebCore::InspectorStorageAgent::create): (WebCore::InspectorStorageAgent::frontend):
  • inspector/front-end/Database.js: (WebInspector.Database.prototype.executeSql): (WebInspector.sqlTransactionSucceeded): (WebInspector.sqlTransactionFailed):
  • inspector/front-end/DatabaseQueryView.js: (WebInspector.DatabaseQueryView.prototype._queryFinished): (WebInspector.DatabaseQueryView.prototype._queryError):
  • inspector/front-end/DatabaseTableView.js: (WebInspector.DatabaseTableView.prototype._queryFinished):
  • inspector/front-end/InjectedScript.js:
  • inspector/front-end/InjectedScriptAccess.js: (InjectedScriptAccess._installHandler.InjectedScriptAccess.prototype.methodName): (InjectedScriptAccess._installHandler):
  • inspector/front-end/StoragePanel.js: (WebInspector.StoragePanel.prototype.dataGridForResult):
Location:
trunk/WebCore
Files:
1 added
26 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/CMakeLists.txt

    r65059 r65072  
    10631063    inspector/InspectorResource.cpp
    10641064    inspector/InspectorValues.cpp
     1065    inspector/InspectorStorageAgent.cpp
    10651066    inspector/InspectorTimelineAgent.cpp
    10661067    inspector/ScriptBreakpoint.cpp
  • trunk/WebCore/ChangeLog

    r65071 r65072  
     12010-08-10  Pavel Feldman  <pfeldman@chromium.org>
     2
     3        Reviewed by Yury Semikhatsky.
     4
     5        Web Inspector: move database processing to native layer.
     6
     7        https://bugs.webkit.org/show_bug.cgi?id=43788
     8
     9        * English.lproj/localizedStrings.js:
     10        * WebCore.gypi:
     11        * bindings/js/JSInjectedScriptHostCustom.cpp:
     12        * bindings/v8/custom/V8InjectedScriptHostCustom.cpp:
     13        * inspector/CodeGeneratorInspector.pm:
     14        * inspector/InjectedScript.cpp:
     15        (WebCore::InjectedScript::dispatch):
     16        * inspector/InjectedScript.h:
     17        * inspector/InjectedScriptHost.cpp:
     18        * inspector/InjectedScriptHost.h:
     19        * inspector/InjectedScriptHost.idl:
     20        * inspector/Inspector.idl:
     21        * inspector/InspectorBackend.cpp:
     22        (WebCore::InspectorBackend::dispatchOnInjectedScript):
     23        (WebCore::InspectorBackend::executeSQL):
     24        * inspector/InspectorBackend.h:
     25        * inspector/InspectorController.cpp:
     26        (WebCore::InspectorController::connectFrontend):
     27        (WebCore::InspectorController::releaseFrontendLifetimeAgents):
     28        * inspector/InspectorController.h:
     29        * inspector/InspectorDebuggerAgent.h:
     30        * inspector/InspectorStorageAgent.cpp: Added.
     31        (WebCore::):
     32        (WebCore::InspectorStorageAgent::InspectorStorageAgent):
     33        (WebCore::InspectorStorageAgent::~InspectorStorageAgent):
     34        (WebCore::InspectorStorageAgent::executeSQL):
     35        (WebCore::InspectorStorageAgent::clearFrontend):
     36        * inspector/InspectorStorageAgent.h: Added.
     37        (WebCore::InspectorStorageAgent::create):
     38        (WebCore::InspectorStorageAgent::frontend):
     39        * inspector/front-end/Database.js:
     40        (WebInspector.Database.prototype.executeSql):
     41        (WebInspector.sqlTransactionSucceeded):
     42        (WebInspector.sqlTransactionFailed):
     43        * inspector/front-end/DatabaseQueryView.js:
     44        (WebInspector.DatabaseQueryView.prototype._queryFinished):
     45        (WebInspector.DatabaseQueryView.prototype._queryError):
     46        * inspector/front-end/DatabaseTableView.js:
     47        (WebInspector.DatabaseTableView.prototype._queryFinished):
     48        * inspector/front-end/InjectedScript.js:
     49        * inspector/front-end/InjectedScriptAccess.js:
     50        (InjectedScriptAccess._installHandler.InjectedScriptAccess.prototype.methodName):
     51        (InjectedScriptAccess._installHandler):
     52        * inspector/front-end/StoragePanel.js:
     53        (WebInspector.StoragePanel.prototype.dataGridForResult):
     54
    1552010-08-10  Steve Block  <steveblock@google.com>
    256
  • trunk/WebCore/GNUmakefile.am

    r65059 r65072  
    16231623        WebCore/inspector/InspectorResource.cpp \
    16241624        WebCore/inspector/InspectorResource.h \
     1625        WebCore/inspector/InspectorStorageAgent.cpp \
     1626        WebCore/inspector/InspectorStorageAgent.h \
    16251627        WebCore/inspector/InspectorTimelineAgent.cpp \
    16261628        WebCore/inspector/InspectorTimelineAgent.h \
  • trunk/WebCore/WebCore.gypi

    r65059 r65072  
    17621762            'inspector/InspectorResource.cpp',
    17631763            'inspector/InspectorResource.h',
     1764            'inspector/InspectorStorageAgent.cpp',
     1765            'inspector/InspectorStorageAgent.h',
    17641766            'inspector/InspectorTimelineAgent.cpp',
    17651767            'inspector/InspectorTimelineAgent.h',
  • trunk/WebCore/WebCore.pro

    r65070 r65072  
    759759    inspector/InspectorFrontendHost.cpp \
    760760    inspector/InspectorResource.cpp \
     761    inspector/InspectorStorageAgent.cpp \
    761762    inspector/InspectorTimelineAgent.cpp \
    762763    inspector/InspectorValues.cpp \
     
    15191520    inspector/InspectorFrontendHost.h \
    15201521    inspector/InspectorResource.h \
     1522    inspector/InspectorStorageAgent.h \
    15211523    inspector/InspectorTimelineAgent.h \
    15221524    inspector/ScriptGCEventListener.h \
  • trunk/WebCore/WebCore.vcproj/WebCore.vcproj

    r65059 r65072  
    5099050990                        </File>
    5099150991                        <File
     50992                                RelativePath="..\inspector\InspectorStorageAgent.cpp"
     50993                                >
     50994                        </File>
     50995                        <File
     50996                                RelativePath="..\inspector\InspectorStorageAgent.h"
     50997                                >
     50998                        </File>
     50999                        <File
    5099251000                                RelativePath="..\inspector\InspectorTimelineAgent.cpp"
    5099351001                                >
  • trunk/WebCore/WebCore.xcodeproj/project.pbxproj

    r65059 r65072  
    14211421                7A74ECBB101839A600BF939E /* InspectorBackend.h in Headers */ = {isa = PBXBuildFile; fileRef = 7A74ECB9101839A600BF939E /* InspectorBackend.h */; };
    14221422                7A74ECBD101839DA00BF939E /* JSInspectorFrontendHostCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7A74ECBC101839DA00BF939E /* JSInspectorFrontendHostCustom.cpp */; };
     1423                7AB0B1C01211A62200A76940 /* InspectorStorageAgent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7AB0B1BE1211A62200A76940 /* InspectorStorageAgent.cpp */; };
     1424                7AB0B1C11211A62200A76940 /* InspectorStorageAgent.h in Headers */ = {isa = PBXBuildFile; fileRef = 7AB0B1BF1211A62200A76940 /* InspectorStorageAgent.h */; };
    14231425                7ADE722610CBBB9B006B3B3A /* ContextMenuProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 7ADE722510CBBB9B006B3B3A /* ContextMenuProvider.h */; };
    14241426                7AFD4A8B1131C2760035B883 /* ScriptBreakpoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 7AFD4A8A1131C2760035B883 /* ScriptBreakpoint.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    72577259                7A74ECB9101839A600BF939E /* InspectorBackend.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorBackend.h; sourceTree = "<group>"; };
    72587260                7A74ECBC101839DA00BF939E /* JSInspectorFrontendHostCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSInspectorFrontendHostCustom.cpp; sourceTree = "<group>"; };
     7261                7AB0B1BE1211A62200A76940 /* InspectorStorageAgent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorStorageAgent.cpp; sourceTree = "<group>"; };
     7262                7AB0B1BF1211A62200A76940 /* InspectorStorageAgent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorStorageAgent.h; sourceTree = "<group>"; };
    72597263                7ADE722510CBBB9B006B3B3A /* ContextMenuProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContextMenuProvider.h; sourceTree = "<group>"; };
    72607264                7AFD4A8A1131C2760035B883 /* ScriptBreakpoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptBreakpoint.h; sourceTree = "<group>"; };
     
    1166311667                                41F062000F5F0B6600A07EAC /* InspectorResource.cpp */,
    1166411668                                41F061FF0F5F0B6600A07EAC /* InspectorResource.h */,
     11669                                7AB0B1BE1211A62200A76940 /* InspectorStorageAgent.cpp */,
     11670                                7AB0B1BF1211A62200A76940 /* InspectorStorageAgent.h */,
    1166511671                                754133A9102E00F400075D00 /* InspectorTimelineAgent.cpp */,
    1166611672                                754133A7102E00E800075D00 /* InspectorTimelineAgent.h */,
     
    2013420140                                97DD4D870FDF4D6E00ECF9A4 /* XSSAuditor.h in Headers */,
    2013520141                                CE172E011136E8CE0062A533 /* ZoomMode.h in Headers */,
     20142                                7AB0B1C11211A62200A76940 /* InspectorStorageAgent.h in Headers */,
    2013620143                        );
    2013720144                        runOnlyForDeploymentPostprocessing = 0;
     
    2255622563                                E1BE512D0CF6C512002EA959 /* XSLTUnicodeSort.cpp in Sources */,
    2255722564                                97DD4D860FDF4D6E00ECF9A4 /* XSSAuditor.cpp in Sources */,
     22565                                7AB0B1C01211A62200A76940 /* InspectorStorageAgent.cpp in Sources */,
    2255822566                        );
    2255922567                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/WebCore/bindings/js/JSInjectedScriptHostCustom.cpp

    r64653 r65072  
    104104}
    105105
    106 #if ENABLE(DATABASE)
    107 JSValue JSInjectedScriptHost::databaseForId(ExecState* exec)
    108 {
    109     if (exec->argumentCount() < 1)
    110         return jsUndefined();
    111 
    112     InspectorController* ic = impl()->inspectorController();
    113     if (!ic)
    114         return jsUndefined();
    115 
    116     Database* database = impl()->databaseForId(exec->argument(0).toInt32(exec));
    117     if (!database)
    118         return jsUndefined();
    119     return toJS(exec, database);
    120 }
    121 #endif
    122 
    123106#if ENABLE(JAVASCRIPT_DEBUGGER)
    124107JSValue JSInjectedScriptHost::currentCallFrame(ExecState* exec)
     
    192175}
    193176#endif
    194 
    195 JSValue JSInjectedScriptHost::reportDidDispatchOnInjectedScript(ExecState* exec)
    196 {
    197     if (exec->argumentCount() < 3)
    198         return jsUndefined();
    199    
    200     if (!exec->argument(0).isInt32())
    201         return jsUndefined();
    202     int callId = exec->argument(0).asInt32();
    203    
    204     RefPtr<InspectorValue> result = ScriptValue(exec->argument(1)).toInspectorValue(exec);
    205    
    206     bool isException;
    207     if (!exec->argument(2).getBoolean(isException))
    208         return jsUndefined();
    209     impl()->reportDidDispatchOnInjectedScript(callId, result, isException);
    210     return jsUndefined();
    211 }
    212177
    213178InjectedScript InjectedScriptHost::injectedScriptFor(ScriptState* scriptState)
  • trunk/WebCore/bindings/v8/custom/V8InjectedScriptHostCustom.cpp

    r64653 r65072  
    165165
    166166#if ENABLE(DATABASE)
    167 v8::Handle<v8::Value> V8InjectedScriptHost::databaseForIdCallback(const v8::Arguments& args)
    168 {
    169     INC_STATS("InjectedScriptHost.databaseForId()");
    170     if (args.Length() < 1)
    171         return v8::Undefined();
    172 
    173     InjectedScriptHost* host = V8InjectedScriptHost::toNative(args.Holder());
    174     Database* database = host->databaseForId(args[0]->ToInt32()->Value());
    175     if (!database)
    176         return v8::Undefined();
    177     return toV8(database);
    178 }
    179 
    180167v8::Handle<v8::Value> V8InjectedScriptHost::selectDatabaseCallback(const v8::Arguments& args)
    181168{
     
    208195}
    209196#endif
    210 
    211 v8::Handle<v8::Value> V8InjectedScriptHost::reportDidDispatchOnInjectedScriptCallback(const v8::Arguments& args)
    212 {
    213     INC_STATS("InjectedScriptHost.reportDidDispatchOnInjectedScript()");
    214     if (args.Length() < 3)
    215         return v8::Undefined();
    216     InjectedScriptHost* host = V8InjectedScriptHost::toNative(args.Holder());
    217     int callId = args[0]->ToInt32()->Value();
    218     RefPtr<InspectorValue> result = ScriptValue(args[1]).toInspectorValue(ScriptState::current());
    219     bool isException = args[2]->ToBoolean()->Value();
    220     host->reportDidDispatchOnInjectedScript(callId, result, isException);
    221     return v8::Undefined();
    222 }
    223197
    224198InjectedScript InjectedScriptHost::injectedScriptFor(ScriptState* inspectedScriptState)
  • trunk/WebCore/inspector/CodeGeneratorInspector.pm

    r65068 r65072  
    238238
    239239    my $notify = $function->signature->extendedAttributes->{"notify"};
    240     my $async = $function->signature->extendedAttributes->{"async"};
    241     return if !$async && !$notify;
     240    return if !$notify;
    242241    my $functionName = $notify ? $function->signature->name : "did" . ucfirst($function->signature->name);
    243242
     
    342341    }
    343342
    344     my $async = $function->signature->extendedAttributes->{"async"};
    345     my $args = join(", ", (grep($async || !($_ eq "callId"), map($_->name, @inArgs)), map("&" . $_->name, @outArgs)));
     343    my $args = join(", ", (grep(!($_ eq "callId"), map($_->name, @inArgs)), map("&" . $_->name, @outArgs)));
    346344    push(@function, "    $handlerAccessor->$functionName($args);");
    347345
    348     # The results of function call should be transfered back to frontend (except async methods - need to fix that).
    349     if (scalar(grep($_->name eq "callId", @inArgs)) && !$async) {
     346    # The results of function call should be transfered back to frontend.
     347    if (scalar(grep($_->name eq "callId", @inArgs))) {
    350348        my @pushArguments = map("        arguments->push" . $typeTransform{$_->type}->{"accessorSuffix"} . "(" . $_->name . ");", @outArgs);
    351349
  • trunk/WebCore/inspector/InjectedScript.cpp

    r64653 r65072  
    4545}
    4646
    47 void InjectedScript::dispatch(long callId, const String& methodName, const String& arguments, bool async, RefPtr<InspectorValue>* result, bool* hadException)
     47void InjectedScript::dispatch(const String& methodName, const String& arguments, RefPtr<InspectorValue>* result, bool* hadException)
    4848{
    4949    ASSERT(!hasNoValue());
     
    5656    function.appendArgument(methodName);
    5757    function.appendArgument(arguments);
    58     if (async)
    59         function.appendArgument(callId);
    6058    *hadException = false;
    6159    ScriptValue resultValue = function.call(*hadException);
  • trunk/WebCore/inspector/InjectedScript.h

    r65021 r65072  
    4949    bool hasNoValue() const { return m_injectedScriptObject.hasNoValue(); }
    5050
    51     void dispatch(long callId, const String& methodName, const String& arguments, bool async, RefPtr<InspectorValue>* result, bool* hadException);
     51    void dispatch(const String& methodName, const String& arguments, RefPtr<InspectorValue>* result, bool* hadException);
    5252#if ENABLE(JAVASCRIPT_DEBUGGER)
    5353    PassRefPtr<InspectorValue> callFrames();
  • trunk/WebCore/inspector/InjectedScriptHost.cpp

    r64951 r65072  
    143143#endif
    144144
    145 void InjectedScriptHost::reportDidDispatchOnInjectedScript(long callId, PassRefPtr<InspectorValue> result, bool isException)
    146 {
    147     if (RemoteInspectorFrontend* frontend = remoteFrontend())
    148         frontend->didDispatchOnInjectedScript(callId, result, isException);
    149 }
    150 
    151145InjectedScript InjectedScriptHost::injectedScriptForId(long id)
    152146{
  • trunk/WebCore/inspector/InjectedScriptHost.h

    r65053 r65072  
    8383    void didDestroyWorker(long id);
    8484#endif
    85     void reportDidDispatchOnInjectedScript(long callId, PassRefPtr<InspectorValue> result, bool isException);
    8685
    8786    pair<long, ScriptObject> injectScript(const String& source, ScriptState*);
  • trunk/WebCore/inspector/InjectedScriptHost.idl

    r61655 r65072  
    4545
    4646#if defined(ENABLE_DATABASE) && ENABLE_DATABASE
    47         [Custom] DOMObject databaseForId(in long databaseId);
    4847        [Custom] void selectDatabase(in DOMObject database);
    4948#endif
     
    5857        long nextWorkerId();
    5958#endif
    60         [Custom] void reportDidDispatchOnInjectedScript(in long callId, in DOMObject result, in boolean isException);
    6159    };
    6260}
  • trunk/WebCore/inspector/Inspector.idl

    r65052 r65072  
    158158#endif
    159159        [handler=Backend] void setInjectedScriptSource(in String scriptSource);
    160         [handler=Backend, async] void dispatchOnInjectedScript(in long callId, in long injectedScriptId, in String methodName, in String arguments, in boolean async, out Value result, out boolean isException);
     160        [handler=Backend] void dispatchOnInjectedScript(in long callId, in long injectedScriptId, in String methodName, in String arguments, out Value result, out boolean isException);
    161161        [handler=Controller] void addScriptToEvaluateOnLoad(in String scriptSource);
    162162        [handler=Controller] void removeAllScriptsToEvaluateOnLoad();
     
    207207#if defined(ENABLE_DATABASE) && ENABLE_DATABASE
    208208        [handler=Backend] void getDatabaseTableNames(in long callId, in long databaseId, out Array tableNames);
     209        [handler=Backend] void executeSQL(in long callId, in long databaseId, in String query, out boolean success, out long transactionId);
     210        [notify] void sqlTransactionSucceeded(out long transactionId, out Value columnNames, out Value values);
     211        [notify] void sqlTransactionFailed(out long transactionId, out Value sqlError);
    209212#endif
    210213
  • trunk/WebCore/inspector/InspectorBackend.cpp

    r64986 r65072  
    4141#include "InspectorController.h"
    4242#include "InspectorDOMAgent.h"
     43#include "InspectorStorageAgent.h"
    4344#include "RemoteInspectorFrontend.h"
    4445#include "ScriptBreakpoint.h"
     
    8687}
    8788
    88 void InspectorBackend::dispatchOnInjectedScript(long callId, long injectedScriptId, const String& methodName, const String& arguments, bool async, RefPtr<InspectorValue>* result, bool* hadException)
     89void InspectorBackend::dispatchOnInjectedScript(long injectedScriptId, const String& methodName, const String& arguments, RefPtr<InspectorValue>* result, bool* hadException)
    8990{
    9091    if (!remoteFrontend())
     
    103104        return;
    104105
    105     injectedScript.dispatch(callId, methodName, arguments, async, result, hadException);
    106     if (async)
    107         return;  // InjectedScript will return result asynchronously by means of ::reportDidDispatchOnInjectedScript.
    108     remoteFrontend()->didDispatchOnInjectedScript(callId, (*result).get(), *hadException);
     106    injectedScript.dispatch(methodName, arguments, result, hadException);
    109107}
    110108
     
    130128    }
    131129}
     130
     131void InspectorBackend::executeSQL(long databaseId, const String& query, bool* success, long* transactionId)
     132{
     133    Database* database = m_inspectorController->databaseForId(databaseId);
     134    if (!m_inspectorController->m_storageAgent || !database) {
     135        *success = false;
     136        return;
     137    }
     138
     139    *transactionId = m_inspectorController->m_storageAgent->executeSQL(database, query);
     140    *success = true;
     141}
     142
    132143#endif
    133144
  • trunk/WebCore/inspector/InspectorBackend.h

    r64986 r65072  
    6767
    6868    void setInjectedScriptSource(const String& source);
    69     void dispatchOnInjectedScript(long callId, long injectedScriptId, const String& methodName, const String& arguments, bool async, RefPtr<InspectorValue>* result, bool* hadException);
     69    void dispatchOnInjectedScript(long injectedScriptId, const String& methodName, const String& arguments, RefPtr<InspectorValue>* result, bool* hadException);
    7070    void clearConsoleMessages();
    7171
     
    7575#if ENABLE(DATABASE)
    7676    void getDatabaseTableNames(long databaseId, RefPtr<InspectorArray>* names);
     77    void executeSQL(long databaseId, const String& query, bool* success, long* transactionId);
    7778#endif
    7879
  • trunk/WebCore/inspector/InspectorController.cpp

    r65068 r65072  
    6464#include "InspectorDebuggerAgent.h"
    6565#include "InspectorResource.h"
     66#include "InspectorStorageAgent.h"
     67#include "InspectorTimelineAgent.h"
    6668#include "InspectorValues.h"
    6769#include "InspectorWorkerResource.h"
    68 #include "InspectorTimelineAgent.h"
    6970#include "Page.h"
    7071#include "ProgressTracker.h"
     
    478479    m_remoteFrontend = new RemoteInspectorFrontend(m_client);
    479480    m_domAgent = InspectorDOMAgent::create(m_cssStore.get(), m_remoteFrontend.get());
     481
     482#if ENABLE(DATABASE)
     483    m_storageAgent = InspectorStorageAgent::create(m_remoteFrontend.get());
     484#endif
     485
    480486    if (m_timelineAgent)
    481487        m_timelineAgent->resetFrontendProxyObject(m_remoteFrontend.get());
     
    599605        m_domAgent->reset();
    600606    m_domAgent.clear();
     607    if (m_storageAgent)
     608        m_storageAgent->clearFrontend();
     609    m_storageAgent.clear();
    601610
    602611#if ENABLE(OFFLINE_WEB_APPLICATIONS)
  • trunk/WebCore/inspector/InspectorController.h

    r65068 r65072  
    6666class InspectorFrontendClient;
    6767class InspectorResource;
     68class InspectorStorageAgent;
    6869class InspectorTimelineAgent;
    6970class InspectorValue;
     
    329330    OwnPtr<RemoteInspectorFrontend> m_remoteFrontend;
    330331    RefPtr<InspectorDOMAgent> m_domAgent;
     332    RefPtr<InspectorStorageAgent> m_storageAgent;
    331333    OwnPtr<InspectorCSSStore> m_cssStore;
    332334    OwnPtr<InspectorTimelineAgent> m_timelineAgent;
  • trunk/WebCore/inspector/InspectorStorageAgent.h

    r65071 r65072  
    11/*
    2  * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
     2 * Copyright (C) 2010 Google Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2727 */
    2828
    29 WebInspector.Database = function(id, domain, name, version)
    30 {
    31     this._id = id;
    32     this._domain = domain;
    33     this._name = name;
    34     this._version = version;
    35 }
     29#ifndef InspectorStorageAgent_h
     30#define InspectorStorageAgent_h
    3631
    37 WebInspector.Database.prototype = {
    38     get id()
     32#include "PlatformString.h"
     33#include "wtf/PassRefPtr.h"
     34
     35namespace WebCore {
     36
     37class Database;
     38class RemoteInspectorFrontend;
     39
     40class InspectorStorageAgent : public RefCounted<InspectorStorageAgent> {
     41public:
     42    static PassRefPtr<InspectorStorageAgent> create(RemoteInspectorFrontend* frontend)
    3943    {
    40         return this._id;
    41     },
     44        return adoptRef(new InspectorStorageAgent(frontend));
     45    }
    4246
    43     get name()
    44     {
    45         return this._name;
    46     },
     47    virtual ~InspectorStorageAgent();
    4748
    48     set name(x)
    49     {
    50         this._name = x;
    51     },
     49    long executeSQL(Database*, const String& query);
    5250
    53     get version()
    54     {
    55         return this._version;
    56     },
     51    RemoteInspectorFrontend* frontend() { return m_frontend; }
     52    void clearFrontend();
    5753
    58     set version(x)
    59     {
    60         this._version = x;
    61     },
     54private:
     55    InspectorStorageAgent(RemoteInspectorFrontend*);
    6256
    63     get domain()
    64     {
    65         return this._domain;
    66     },
     57    RemoteInspectorFrontend* m_frontend;
     58};
    6759
    68     set domain(x)
    69     {
    70         this._domain = x;
    71     },
     60} // namespace WebCore
    7261
    73     get displayDomain()
    74     {
    75         return WebInspector.Resource.prototype.__lookupGetter__("displayDomain").call(this);
    76     },
    77 
    78     getTableNames: function(callback)
    79     {
    80         function sortingCallback(names)
    81         {
    82             callback(names.sort());
    83         }
    84         var callId = WebInspector.Callback.wrap(sortingCallback);
    85         InspectorBackend.getDatabaseTableNames(callId, this._id);
    86     },
    87    
    88     executeSql: function(query, onSuccess, onError)
    89     {
    90         function callback(result)
    91         {
    92             if (!(result instanceof Array)) {
    93                 onError(result);
    94                 return;
    95             }
    96             onSuccess(result);
    97         }
    98         // FIXME: execute the query in the frame the DB comes from.
    99         InjectedScriptAccess.getDefault().executeSql(this._id, query, callback);
    100     }
    101 }
    102 
     62#endif // !defined(InspectorStorageAgent_h)
  • trunk/WebCore/inspector/front-end/Database.js

    r65052 r65072  
    3434    this._version = version;
    3535}
     36
     37WebInspector.Database.successCallbacks = {};
     38WebInspector.Database.errorCallbacks = {};
    3639
    3740WebInspector.Database.prototype = {
     
    8891    executeSql: function(query, onSuccess, onError)
    8992    {
    90         function callback(result)
     93        function callback(success, transactionId)
    9194        {
    92             if (!(result instanceof Array)) {
    93                 onError(result);
     95            if (!success) {
     96                onError(WebInspector.UIString("Database not found."));
    9497                return;
    9598            }
    96             onSuccess(result);
     99            WebInspector.Database.successCallbacks[transactionId] = onSuccess;
     100            WebInspector.Database.errorCallbacks[transactionId] = onError;
    97101        }
    98         // FIXME: execute the query in the frame the DB comes from.
    99         InjectedScriptAccess.getDefault().executeSql(this._id, query, callback);
     102        InspectorBackend.executeSQL(WebInspector.Callback.wrap(callback), this._id, query);
    100103    }
    101104}
    102105
     106WebInspector.sqlTransactionSucceeded = function(transactionId, columnNames, values)
     107{
     108    var callback = WebInspector.Database.successCallbacks[transactionId];
     109    if (!callback)
     110        return;
     111    delete WebInspector.Database.successCallbacks[transactionId];
     112    callback(columnNames, values);
     113}
     114
     115WebInspector.sqlTransactionFailed = function(transactionId, errorObj)
     116{
     117    var callback = WebInspector.Database.errorCallbacks[transactionId];
     118    if (!callback)
     119        return;
     120    delete WebInspector.Database.errorCallbacks[transactionId];
     121    callback(errorObj);
     122}
  • trunk/WebCore/inspector/front-end/DatabaseQueryView.js

    r57789 r65072  
    138138    },
    139139
    140     _queryFinished: function(query, result)
     140    _queryFinished: function(query, columnNames, values)
    141141    {
    142         var dataGrid = WebInspector.panels.storage.dataGridForResult(result);
     142        var dataGrid = WebInspector.panels.storage.dataGridForResult(columnNames, values);
    143143        var trimmedQuery = query.trim();
    144144
     
    155155    _queryError: function(query, error)
    156156    {
    157         if (error.code == 1)
     157        if (error.message)
    158158            var message = error.message;
    159159        else if (error.code == 2)
  • trunk/WebCore/inspector/front-end/DatabaseTableView.js

    r54436 r65072  
    5555    },
    5656
    57     _queryFinished: function(result)
     57    _queryFinished: function(columnNames, values)
    5858    {
    5959        this.element.removeChildren();
    6060
    61         var dataGrid = WebInspector.panels.storage.dataGridForResult(result);
     61        var dataGrid = WebInspector.panels.storage.dataGridForResult(columnNames, values);
    6262        if (!dataGrid) {
    6363            var emptyMsgElement = document.createElement("div");
  • trunk/WebCore/inspector/front-end/InjectedScript.js

    r64458 r65072  
    473473}
    474474
    475 InjectedScript.executeSql = function(callId, databaseId, query)
    476 {
    477     function successCallback(tx, result)
    478     {
    479         var rows = result.rows;
    480         var result = [];
    481         var length = rows.length;
    482         for (var i = 0; i < length; ++i) {
    483             var data = {};
    484             result.push(data);
    485             var row = rows.item(i);
    486             for (var columnIdentifier in row) {
    487                 // FIXME: (Bug 19439) We should specially format SQL NULL here
    488                 // (which is represented by JavaScript null here, and turned
    489                 // into the string "null" by the String() function).
    490                 var text = row[columnIdentifier];
    491                 data[columnIdentifier] = String(text);
    492             }
    493         }
    494         InjectedScriptHost.reportDidDispatchOnInjectedScript(callId, result, false);
    495     }
    496 
    497     function errorCallback(tx, error)
    498     {
    499         InjectedScriptHost.reportDidDispatchOnInjectedScript(callId, error, false);
    500     }
    501 
    502     function queryTransaction(tx)
    503     {
    504         tx.executeSql(query, null, successCallback, errorCallback);
    505     }
    506 
    507     var database = InjectedScriptHost.databaseForId(databaseId);
    508     if (!database)
    509         errorCallback(null, { code : 2 });  // Return as unexpected version.
    510     database.transaction(queryTransaction, errorCallback);
    511     return true;
    512 }
    513 
    514475InjectedScript._isDefined = function(object)
    515476{
  • trunk/WebCore/inspector/front-end/InjectedScriptAccess.js

    r65052 r65072  
    6767        var callId = WebInspector.Callback.wrap(myCallback);
    6868
    69         InspectorBackend.dispatchOnInjectedScript(callId, this._injectedScriptId, methodName, argsString, !!async);
     69        InspectorBackend.dispatchOnInjectedScript(callId, this._injectedScriptId, methodName, argsString);
    7070    };
    7171}
     
    8585InjectedScriptAccess._installHandler("pushNodeToFrontend");
    8686InjectedScriptAccess._installHandler("setPropertyValue");
    87 
    88 // Some methods can't run synchronously even on the injected script side (such as DB transactions).
    89 // Mark them as asynchronous here.
    90 InjectedScriptAccess._installHandler("executeSql", true);
    91 
  • trunk/WebCore/inspector/front-end/StoragePanel.js

    r64265 r65072  
    299299    },
    300300
    301     dataGridForResult: function(rows)
    302     {
    303         if (!rows.length)
     301    dataGridForResult: function(columnNames, values)
     302    {
     303        var numColumns = columnNames.length;
     304        if (!numColumns)
    304305            return null;
    305306
    306307        var columns = {};
    307         var numColumns = 0;
    308 
    309         for (var columnIdentifier in rows[0]) {
     308
     309        for (var i = 0; i < columnNames.length; ++i) {
    310310            var column = {};
    311             column.width = columnIdentifier.length;
    312             column.title = columnIdentifier;
     311            column.width = columnNames[i].length;
     312            column.title = columnNames[i];
    313313            column.sortable = true;
    314314
    315             columns[columnIdentifier] = column;
    316             ++numColumns;
     315            columns[columnNames[i]] = column;
    317316        }
    318317
    319318        var nodes = [];
    320         var length = rows.length;
    321         for (var i = 0; i < length; ++i) {
     319        for (var i = 0; i < values.length / numColumns; ++i) {
    322320            var data = {};
    323 
    324             var row = rows[i];
    325             for (var columnIdentifier in row)
    326                 data[columnIdentifier] = row[columnIdentifier];
     321            for (var j = 0; j < columnNames.length; ++j)
     322                data[columnNames[j]] = values[numColumns * i + j];
    327323
    328324            var node = new WebInspector.DataGridNode(data, false);
Note: See TracChangeset for help on using the changeset viewer.