Changeset 113213 in webkit


Ignore:
Timestamp:
Apr 4, 2012 10:43:27 AM (12 years ago)
Author:
caseq@chromium.org
Message:

Web Inspector: CodeGeneratorInspector.py: switch IndexedDB, DOMStorage, ApplicationCache domains to typed API
https://bugs.webkit.org/show_bug.cgi?id=83039

Patch by Peter Rybin <peter.rybin@gmail.com> on 2012-04-04
Reviewed by Pavel Feldman.

Client code is switched to typed API (all InspectorObject and InspectorArray types are
replaced with generated types from TypeBuilder according to Inspector.json).

Missing array of array specialization is added. Inspector.json is fixed to comform
with actual behavior of InspectorDOMStorageAgent.

Output parameter initialization is assured.

  • inspector/CodeGeneratorInspector.py:
  • inspector/Inspector.json:
  • inspector/InspectorApplicationCacheAgent.cpp:

(WebCore::InspectorApplicationCacheAgent::getFramesWithManifests):
(WebCore::InspectorApplicationCacheAgent::getApplicationCacheForFrame):
(WebCore::InspectorApplicationCacheAgent::buildObjectForApplicationCache):

  • inspector/InspectorApplicationCacheAgent.h:

(InspectorApplicationCacheAgent):

  • inspector/InspectorDOMStorageAgent.cpp:

(WebCore::InspectorDOMStorageAgent::getDOMStorageEntries):
(WebCore::InspectorDOMStorageAgent::setDOMStorageItem):
(WebCore::InspectorDOMStorageAgent::removeDOMStorageItem):

  • inspector/InspectorDOMStorageAgent.h:

(InspectorDOMStorageAgent):

  • inspector/InspectorDOMStorageResource.cpp:

(WebCore::InspectorDOMStorageResource::bind):

Location:
trunk/Source/WebCore
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r113208 r113213  
     12012-04-04  Peter Rybin  <peter.rybin@gmail.com>
     2
     3        Web Inspector: CodeGeneratorInspector.py: switch IndexedDB, DOMStorage, ApplicationCache domains to typed API
     4        https://bugs.webkit.org/show_bug.cgi?id=83039
     5
     6        Reviewed by Pavel Feldman.
     7
     8        Client code is switched to typed API (all InspectorObject and InspectorArray types are
     9        replaced with generated types from TypeBuilder according to Inspector.json).
     10
     11        Missing array of array specialization is added. Inspector.json is fixed to comform
     12        with actual behavior of InspectorDOMStorageAgent.
     13
     14        Output parameter initialization is assured.
     15
     16        * inspector/CodeGeneratorInspector.py:
     17        * inspector/Inspector.json:
     18        * inspector/InspectorApplicationCacheAgent.cpp:
     19        (WebCore::InspectorApplicationCacheAgent::getFramesWithManifests):
     20        (WebCore::InspectorApplicationCacheAgent::getApplicationCacheForFrame):
     21        (WebCore::InspectorApplicationCacheAgent::buildObjectForApplicationCache):
     22        * inspector/InspectorApplicationCacheAgent.h:
     23        (InspectorApplicationCacheAgent):
     24        * inspector/InspectorDOMStorageAgent.cpp:
     25        (WebCore::InspectorDOMStorageAgent::getDOMStorageEntries):
     26        (WebCore::InspectorDOMStorageAgent::setDOMStorageItem):
     27        (WebCore::InspectorDOMStorageAgent::removeDOMStorageItem):
     28        * inspector/InspectorDOMStorageAgent.h:
     29        (InspectorDOMStorageAgent):
     30        * inspector/InspectorDOMStorageResource.cpp:
     31        (WebCore::InspectorDOMStorageResource::bind):
     32
    1332012-04-04  Tony Chang  <tony@chromium.org>
    234
  • trunk/Source/WebCore/inspector/CodeGeneratorInspector.py

    r113157 r113213  
    6262STRICT_ENABLED_DOMAINS = ["Console", "DOMDebugger",
    6363                          "CSS", "Debugger", "DOM", "Network", "Page", "Runtime",
    64                           "Inspector", "Memory", "Database"]
     64                          "Inspector", "Memory", "Database",
     65                          "IndexedDB", "DOMStorage", "ApplicationCache"]
    6566
    6667
     
    22892290};
    22902291
     2292template<typename T>
     2293struct ArrayItemHelper<TypeBuilder::Array<T> > {
     2294    struct Traits {
     2295        static void pushRefPtr(InspectorArray* array, PassRefPtr<TypeBuilder::Array<T> > value)
     2296        {
     2297            array->pushArray(value);
     2298        }
     2299    };
     2300};
     2301
    22912302${forwards}
    22922303
  • trunk/Source/WebCore/inspector/Inspector.json

    r113013 r113213  
    11321132                    { "name": "id", "$ref": "StorageId", "description": "Entry id for further reference." }
    11331133                ]
     1134            },
     1135            {
     1136                "id": "Item",
     1137                "type": "array",
     1138                "description": "DOM Storage item.",
     1139                "hidden": true,
     1140                "items": { "type": "string" }
    11341141            }
    11351142        ],
     
    11491156                ],
    11501157                "returns": [
    1151                     { "name": "entries", "type": "array", "items": { "$ref": "Entry"} }
     1158                    { "name": "entries", "type": "array", "items": { "$ref": "Item" } }
    11521159                ]
    11531160            },
  • trunk/Source/WebCore/inspector/InspectorApplicationCacheAgent.cpp

    r110854 r113213  
    105105}
    106106
    107 void InspectorApplicationCacheAgent::getFramesWithManifests(ErrorString*, RefPtr<InspectorArray>& result)
    108 {
    109     result = InspectorArray::create();
     107void InspectorApplicationCacheAgent::getFramesWithManifests(ErrorString*, RefPtr<TypeBuilder::Array<TypeBuilder::ApplicationCache::FrameWithManifest> >& result)
     108{
     109    result = TypeBuilder::Array<TypeBuilder::ApplicationCache::FrameWithManifest>::create();
    110110
    111111    Frame* mainFrame = m_pageAgent->mainFrame();
     
    119119        String manifestURL = info.m_manifest.string();
    120120        if (!manifestURL.isEmpty()) {
    121             RefPtr<InspectorObject> value = InspectorObject::create();
    122             value->setString("frameId", m_pageAgent->frameId(frame));
    123             value->setString("manifestURL", manifestURL);
    124             value->setNumber("status", host->status());
    125             result->pushObject(value);
     121            RefPtr<TypeBuilder::ApplicationCache::FrameWithManifest> value = TypeBuilder::ApplicationCache::FrameWithManifest::create()
     122                .setFrameId(m_pageAgent->frameId(frame))
     123                .setManifestURL(manifestURL)
     124                .setStatus(host->status());
     125            result->addItem(value);
    126126        }
    127127    }
     
    147147}
    148148
    149 void InspectorApplicationCacheAgent::getApplicationCacheForFrame(ErrorString* errorString, const String& frameId, RefPtr<InspectorObject>& applicationCache)
     149void InspectorApplicationCacheAgent::getApplicationCacheForFrame(ErrorString* errorString, const String& frameId, RefPtr<TypeBuilder::ApplicationCache::ApplicationCache>& applicationCache)
    150150{
    151151    DocumentLoader* documentLoader = assertFrameWithDocumentLoader(errorString, frameId);
     
    162162}
    163163
    164 PassRefPtr<InspectorObject> InspectorApplicationCacheAgent::buildObjectForApplicationCache(const ApplicationCacheHost::ResourceInfoList& applicationCacheResources, const ApplicationCacheHost::CacheInfo& applicationCacheInfo)
    165 {
    166     RefPtr<InspectorObject> value = InspectorObject::create();
    167     value->setNumber("size", applicationCacheInfo.m_size);
    168     value->setString("manifestURL", applicationCacheInfo.m_manifest.string());
    169     value->setNumber("creationTime", applicationCacheInfo.m_creationTime);
    170     value->setNumber("updateTime", applicationCacheInfo.m_updateTime);
    171     value->setArray("resources", buildArrayForApplicationCacheResources(applicationCacheResources));
    172     return value;
     164PassRefPtr<TypeBuilder::ApplicationCache::ApplicationCache> InspectorApplicationCacheAgent::buildObjectForApplicationCache(const ApplicationCacheHost::ResourceInfoList& applicationCacheResources, const ApplicationCacheHost::CacheInfo& applicationCacheInfo)
     165{
     166    return TypeBuilder::ApplicationCache::ApplicationCache::create()
     167        .setManifestURL(applicationCacheInfo.m_manifest.string())
     168        .setSize(applicationCacheInfo.m_size)
     169        .setCreationTime(applicationCacheInfo.m_creationTime)
     170        .setUpdateTime(applicationCacheInfo.m_updateTime)
     171        .setResources(buildArrayForApplicationCacheResources(applicationCacheResources));
    173172}
    174173
  • trunk/Source/WebCore/inspector/InspectorApplicationCacheAgent.h

    r106777 r113213  
    7070    // ApplicationCache API for InspectorFrontend
    7171    virtual void enable(ErrorString*);
    72     virtual void getFramesWithManifests(ErrorString*, RefPtr<InspectorArray>& result);
     72    virtual void getFramesWithManifests(ErrorString*, RefPtr<TypeBuilder::Array<TypeBuilder::ApplicationCache::FrameWithManifest> >& result);
    7373    virtual void getManifestForFrame(ErrorString*, const String& frameId, String* manifestURL);
    74     virtual void getApplicationCacheForFrame(ErrorString*, const String& frameId, RefPtr<InspectorObject>& applicationCache);
     74    virtual void getApplicationCacheForFrame(ErrorString*, const String& frameId, RefPtr<TypeBuilder::ApplicationCache::ApplicationCache>&);
    7575
    7676private:
    7777    InspectorApplicationCacheAgent(InstrumentingAgents*, InspectorState*, InspectorPageAgent*);
    78     PassRefPtr<InspectorObject> buildObjectForApplicationCache(const ApplicationCacheHost::ResourceInfoList&, const ApplicationCacheHost::CacheInfo&);
     78    PassRefPtr<TypeBuilder::ApplicationCache::ApplicationCache> buildObjectForApplicationCache(const ApplicationCacheHost::ResourceInfoList&, const ApplicationCacheHost::CacheInfo&);
    7979    PassRefPtr<InspectorArray> buildArrayForApplicationCacheResources(const ApplicationCacheHost::ResourceInfoList&);
    8080    PassRefPtr<InspectorObject> buildObjectForApplicationCacheResource(const ApplicationCacheHost::ResourceInfo&);
  • trunk/Source/WebCore/inspector/InspectorDOMStorageAgent.cpp

    r113013 r113213  
    109109}
    110110
    111 void InspectorDOMStorageAgent::getDOMStorageEntries(ErrorString*, const String& storageId, RefPtr<InspectorArray>& entries)
    112 {
     111void InspectorDOMStorageAgent::getDOMStorageEntries(ErrorString*, const String& storageId, RefPtr<TypeBuilder::Array<TypeBuilder::Array<String> > >& entries)
     112{
     113    // FIXME: consider initializing this array after 2 checks below. The checks should return error messages in this case.
     114    entries = TypeBuilder::Array<TypeBuilder::Array<String> >::create();
     115
    113116    InspectorDOMStorageResource* storageResource = getDOMStorageResourceForId(storageId);
    114117    if (!storageResource)
     
    123126        String name(storageArea->key(i, frame));
    124127        String value(storageArea->getItem(name, frame));
    125         RefPtr<InspectorArray> entry = InspectorArray::create();
    126         entry->pushString(name);
    127         entry->pushString(value);
    128         entries->pushArray(entry);
     128        RefPtr<TypeBuilder::Array<String> > entry = TypeBuilder::Array<String>::create();
     129        entry->addItem(name);
     130        entry->addItem(value);
     131        entries->addItem(entry);
    129132    }
    130133}
     
    137140        storageResource->storageArea()->setItem(key, value, exception, storageResource->frame());
    138141        *success = !exception;
    139     }
     142    } else
     143        *success = false;
    140144}
    141145
     
    146150        storageResource->storageArea()->removeItem(key, storageResource->frame());
    147151        *success = true;
    148     }
     152    } else
     153        *success = false;
    149154}
    150155
  • trunk/Source/WebCore/inspector/InspectorDOMStorageAgent.h

    r113013 r113213  
    6565    virtual void enable(ErrorString*);
    6666    virtual void disable(ErrorString*);
    67     virtual void getDOMStorageEntries(ErrorString*, const String& storageId, RefPtr<InspectorArray>& entries);
     67    virtual void getDOMStorageEntries(ErrorString*, const String& storageId, RefPtr<TypeBuilder::Array<TypeBuilder::Array<String> > >& entries);
    6868    virtual void setDOMStorageItem(ErrorString*, const String& storageId, const String& key, const String& value, bool* success);
    6969    virtual void removeDOMStorageItem(ErrorString*, const String& storageId, const String& key, bool* success);
  • trunk/Source/WebCore/inspector/InspectorDOMStorageResource.cpp

    r113013 r113213  
    7373    m_frontend = frontend->domstorage();
    7474
    75     RefPtr<InspectorObject> jsonObject = InspectorObject::create();
    76     jsonObject->setString("host", m_frame->document()->securityOrigin()->host());
    77     jsonObject->setBoolean("isLocalStorage", m_isLocalStorage);
    78     jsonObject->setString("id", m_id);
     75    RefPtr<TypeBuilder::DOMStorage::Entry> jsonObject = TypeBuilder::DOMStorage::Entry::create()
     76        .setHost(m_frame->document()->securityOrigin()->host())
     77        .setIsLocalStorage(m_isLocalStorage)
     78        .setId(m_id);
    7979    m_frontend->addDOMStorage(jsonObject);
    8080}
Note: See TracChangeset for help on using the changeset viewer.