Changeset 51439 in webkit


Ignore:
Timestamp:
Nov 27, 2009 3:12:44 AM (14 years ago)
Author:
yurys@chromium.org
Message:

2009-11-27 Yury Semikhatsky <yurys@chromium.org>

Reviewed by Pavel Feldman.

Instead of generating negative identifiers for cached resources in
InspectorController and extending identifier type from 'unsigned long' to 'long
long' reuse progress tracker from the inspected page to generate those
identifiers. It guarantees that InspectorResources have unique ids since
all of them are generated by that progress tracker.

Added a couple new overloaded methods to Script* objects that accept
long and unsigned long arguments. These types of argumens have already
been passed as long long.

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

  • bindings/js/ScriptFunctionCall.cpp: (WebCore::ScriptFunctionCall::appendArgument):
  • bindings/js/ScriptFunctionCall.h:
  • bindings/js/ScriptObject.cpp: (WebCore::ScriptObject::set):
  • bindings/js/ScriptObject.h:
  • bindings/v8/ScriptFunctionCall.cpp: (WebCore::ScriptFunctionCall::appendArgument):
  • bindings/v8/ScriptFunctionCall.h:
  • bindings/v8/ScriptObject.cpp: (WebCore::ScriptObject::set):
  • bindings/v8/ScriptObject.h:
  • inspector/InspectorBackend.cpp: (WebCore::InspectorBackend::dispatchOnInjectedScript):
  • inspector/InspectorController.cpp: (WebCore::InspectorController::InspectorController): (WebCore::InspectorController::getTrackedResource): (WebCore::InspectorController::didLoadResourceFromMemoryCache): Use inspected page's ProgressTracker to generate unique identifiers for cached resources in InspectorController.
  • inspector/InspectorController.h:
  • inspector/InspectorDOMAgent.cpp: (WebCore::InspectorDOMAgent::buildObjectForNode): (WebCore::InspectorDOMAgent::buildObjectForEventListener):
  • inspector/InspectorFrontend.cpp: (WebCore::InspectorFrontend::addResource): (WebCore::InspectorFrontend::updateResource): (WebCore::InspectorFrontend::removeResource): (WebCore::InspectorFrontend::updateFocusedNode):
  • inspector/InspectorFrontend.h:
  • inspector/InspectorResource.cpp: (WebCore::InspectorResource::InspectorResource): (WebCore::InspectorResource::createCached):
  • inspector/InspectorResource.h: Change InspectorResource identifier type from 'long long' to 'unsigned long'. (WebCore::InspectorResource::create): (WebCore::InspectorResource::identifier):
  • inspector/TimelineRecordFactory.cpp: (WebCore::TimelineRecordFactory::createResourceSendRequestRecord): (WebCore::TimelineRecordFactory::createResourceReceiveResponseRecord): (WebCore::TimelineRecordFactory::createResourceFinishRecord):
Location:
trunk/WebCore
Files:
18 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r51429 r51439  
     12009-11-27  Yury Semikhatsky  <yurys@chromium.org>
     2
     3        Reviewed by Pavel Feldman.
     4
     5        Instead of generating negative identifiers for cached resources in
     6        InspectorController and extending identifier type from 'unsigned long' to 'long
     7        long' reuse progress tracker from the inspected page to generate those
     8        identifiers. It guarantees that InspectorResources have unique ids since
     9        all of them are generated by that progress tracker.
     10
     11        Added a couple new overloaded methods to Script* objects that accept
     12        long and unsigned long arguments. These types of argumens have already
     13        been passed as long long.
     14
     15        https://bugs.webkit.org/show_bug.cgi?id=31921
     16
     17        * bindings/js/ScriptFunctionCall.cpp:
     18        (WebCore::ScriptFunctionCall::appendArgument):
     19        * bindings/js/ScriptFunctionCall.h:
     20        * bindings/js/ScriptObject.cpp:
     21        (WebCore::ScriptObject::set):
     22        * bindings/js/ScriptObject.h:
     23        * bindings/v8/ScriptFunctionCall.cpp:
     24        (WebCore::ScriptFunctionCall::appendArgument):
     25        * bindings/v8/ScriptFunctionCall.h:
     26        * bindings/v8/ScriptObject.cpp:
     27        (WebCore::ScriptObject::set):
     28        * bindings/v8/ScriptObject.h:
     29        * inspector/InspectorBackend.cpp:
     30        (WebCore::InspectorBackend::dispatchOnInjectedScript):
     31        * inspector/InspectorController.cpp:
     32        (WebCore::InspectorController::InspectorController):
     33        (WebCore::InspectorController::getTrackedResource):
     34        (WebCore::InspectorController::didLoadResourceFromMemoryCache): Use inspected page's ProgressTracker to generate unique identifiers for cached resources in InspectorController.
     35        * inspector/InspectorController.h:
     36        * inspector/InspectorDOMAgent.cpp:
     37        (WebCore::InspectorDOMAgent::buildObjectForNode):
     38        (WebCore::InspectorDOMAgent::buildObjectForEventListener):
     39        * inspector/InspectorFrontend.cpp:
     40        (WebCore::InspectorFrontend::addResource):
     41        (WebCore::InspectorFrontend::updateResource):
     42        (WebCore::InspectorFrontend::removeResource):
     43        (WebCore::InspectorFrontend::updateFocusedNode):
     44        * inspector/InspectorFrontend.h:
     45        * inspector/InspectorResource.cpp:
     46        (WebCore::InspectorResource::InspectorResource):
     47        (WebCore::InspectorResource::createCached):
     48        * inspector/InspectorResource.h: Change InspectorResource identifier type from 'long long' to 'unsigned long'.
     49        (WebCore::InspectorResource::create):
     50        (WebCore::InspectorResource::identifier):
     51        * inspector/TimelineRecordFactory.cpp:
     52        (WebCore::TimelineRecordFactory::createResourceSendRequestRecord):
     53        (WebCore::TimelineRecordFactory::createResourceReceiveResponseRecord):
     54        (WebCore::TimelineRecordFactory::createResourceFinishRecord):
     55
    1562009-11-26  Shinichiro Hamaji  <hamaji@chromium.org>
    257
  • trunk/WebCore/bindings/js/ScriptFunctionCall.cpp

    r49963 r51439  
    8181}
    8282
     83void ScriptFunctionCall::appendArgument(long argument)
     84{
     85    JSLock lock(SilenceAssertionsOnly);
     86    m_arguments.append(jsNumber(m_exec, argument));
     87}
     88
    8389void ScriptFunctionCall::appendArgument(long long argument)
    8490{
     
    8894
    8995void ScriptFunctionCall::appendArgument(unsigned int argument)
     96{
     97    JSLock lock(SilenceAssertionsOnly);
     98    m_arguments.append(jsNumber(m_exec, argument));
     99}
     100
     101void ScriptFunctionCall::appendArgument(unsigned long argument)
    90102{
    91103    JSLock lock(SilenceAssertionsOnly);
  • trunk/WebCore/bindings/js/ScriptFunctionCall.h

    r43122 r51439  
    5858        void appendArgument(const JSC::UString&);
    5959        void appendArgument(JSC::JSValue);
     60        void appendArgument(long);
    6061        void appendArgument(long long);
    6162        void appendArgument(unsigned int);
     63        void appendArgument(unsigned long);
    6264        void appendArgument(int);
    6365        void appendArgument(bool);
  • trunk/WebCore/bindings/js/ScriptObject.cpp

    r50848 r51439  
    9191}
    9292
     93bool ScriptObject::set(const char* name, long value)
     94{
     95    JSLock lock(SilenceAssertionsOnly);
     96    PutPropertySlot slot;
     97    jsObject()->put(m_scriptState, Identifier(m_scriptState, name), jsNumber(m_scriptState, value), slot);
     98    return handleException(m_scriptState);
     99}
     100
    93101bool ScriptObject::set(const char* name, long long value)
    94102{
     
    108116
    109117bool ScriptObject::set(const char* name, unsigned value)
     118{
     119    JSLock lock(SilenceAssertionsOnly);
     120    PutPropertySlot slot;
     121    jsObject()->put(m_scriptState, Identifier(m_scriptState, name), jsNumber(m_scriptState, value), slot);
     122    return handleException(m_scriptState);
     123}
     124
     125bool ScriptObject::set(const char* name, unsigned long value)
    110126{
    111127    JSLock lock(SilenceAssertionsOnly);
  • trunk/WebCore/bindings/js/ScriptObject.h

    r49263 r51439  
    5151        bool set(const char* name, const String&);
    5252        bool set(const char* name, double);
     53        bool set(const char* name, long);
    5354        bool set(const char* name, long long);
    5455        bool set(const char* name, int);
    5556        bool set(const char* name, unsigned);
     57        bool set(const char* name, unsigned long);
    5658        bool set(const char* name, bool);
    5759
  • trunk/WebCore/bindings/v8/ScriptFunctionCall.cpp

    r48072 r51439  
    7575}
    7676
     77void ScriptFunctionCall::appendArgument(long argument)
     78{
     79    ScriptScope scope(m_scriptState);
     80    m_arguments.append(v8::Number::New(argument));
     81}
     82
    7783void ScriptFunctionCall::appendArgument(long long argument)
    7884{
     
    8288
    8389void ScriptFunctionCall::appendArgument(unsigned int argument)
     90{
     91    ScriptScope scope(m_scriptState);
     92    m_arguments.append(v8::Number::New(argument));
     93}
     94
     95void ScriptFunctionCall::appendArgument(unsigned long argument)
    8496{
    8597    ScriptScope scope(m_scriptState);
  • trunk/WebCore/bindings/v8/ScriptFunctionCall.h

    r42568 r51439  
    5151        void appendArgument(const ScriptValue&);
    5252        void appendArgument(const String&);
     53        void appendArgument(long);
    5354        void appendArgument(long long);
    5455        void appendArgument(unsigned int);
     56        void appendArgument(unsigned long);
    5557        void appendArgument(int);
    5658        void appendArgument(bool);
  • trunk/WebCore/bindings/v8/ScriptObject.cpp

    r49262 r51439  
    8484}
    8585
     86bool ScriptObject::set(const char* name, long value)
     87{
     88    ScriptScope scope(m_scriptState);
     89    v8Object()->Set(v8::String::New(name), v8::Number::New(value));
     90    return scope.success();
     91}
     92
    8693bool ScriptObject::set(const char* name, long long value)
    8794{
     
    99106
    100107bool ScriptObject::set(const char* name, unsigned value)
     108{
     109    ScriptScope scope(m_scriptState);
     110    v8Object()->Set(v8::String::New(name), v8::Number::New(value));
     111    return scope.success();
     112}
     113
     114bool ScriptObject::set(const char* name, unsigned long value)
    101115{
    102116    ScriptScope scope(m_scriptState);
  • trunk/WebCore/bindings/v8/ScriptObject.h

    r49262 r51439  
    5252        bool set(const char* name, const String&);
    5353        bool set(const char* name, double);
     54        bool set(const char* name, long);
    5455        bool set(const char* name, long long);
    5556        bool set(const char* name, int);
    5657        bool set(const char* name, unsigned);
     58        bool set(const char* name, unsigned long);
    5759        bool set(const char* name, bool);
    5860
  • trunk/WebCore/inspector/InspectorBackend.cpp

    r50639 r51439  
    415415    function.appendArgument(arguments);
    416416    if (async)
    417         function.appendArgument(static_cast<int>(callId));
     417        function.appendArgument(callId);
    418418    bool hadException = false;
    419419    ScriptValue result = function.call(hadException);
  • trunk/WebCore/inspector/InspectorController.cpp

    r51422 r51439  
    6363#include "JavaScriptProfile.h"
    6464#include "Page.h"
     65#include "ProgressTracker.h"
    6566#include "Range.h"
    6667#include "RenderInline.h"
     
    129130    , m_windowVisible(false)
    130131    , m_showAfterVisible(CurrentPanel)
    131     , m_nextIdentifier(-2)
    132132    , m_groupLevel(0)
    133133    , m_searchingForNode(false)
     
    842842}
    843843
    844 InspectorResource* InspectorController::getTrackedResource(long long identifier)
     844InspectorResource* InspectorController::getTrackedResource(unsigned long identifier)
    845845{
    846846    if (!enabled())
     
    872872        return;
    873873
    874     RefPtr<InspectorResource> resource = InspectorResource::createCached(m_nextIdentifier--, loader, cachedResource);
     874    RefPtr<InspectorResource> resource = InspectorResource::createCached(m_inspectedPage->progress()->createUniqueIdentifier() , loader, cachedResource);
    875875
    876876    if (isMainResource) {
     
    16101610    ScriptGlobalObject::get(scriptState, "window", window);
    16111611    ScriptFunctionCall function(scriptState, window, "didEvaluateForTestInFrontend");
    1612     function.appendArgument(static_cast<int>(callId));
     1612    function.appendArgument(callId);
    16131613    function.appendArgument(jsonResult);
    16141614    function.call();
  • trunk/WebCore/inspector/InspectorController.h

    r51422 r51439  
    9292                                                    {
    9393public:
    94     typedef HashMap<long long, RefPtr<InspectorResource> > ResourcesMap;
     94    typedef HashMap<unsigned long, RefPtr<InspectorResource> > ResourcesMap;
    9595    typedef HashMap<RefPtr<Frame>, ResourcesMap*> FrameResourcesMap;
    9696    typedef HashMap<int, RefPtr<InspectorDatabaseResource> > DatabaseResourcesMap;
     
    344344    void addResource(InspectorResource*);
    345345    void removeResource(InspectorResource*);
    346     InspectorResource* getTrackedResource(long long identifier);
     346    InspectorResource* getTrackedResource(unsigned long identifier);
    347347
    348348    void pruneResources(ResourcesMap*, DocumentLoader* loaderToKeep = 0);
     
    381381    bool m_windowVisible;
    382382    SpecialPanels m_showAfterVisible;
    383     long long m_nextIdentifier;
    384383    RefPtr<Node> m_highlightedNode;
    385384    unsigned m_groupLevel;
  • trunk/WebCore/inspector/InspectorDOMAgent.cpp

    r50691 r51439  
    467467    }
    468468
    469     value.set("id", static_cast<int>(id));
     469    value.set("id", id);
    470470    value.set("nodeType", node->nodeType());
    471471    value.set("nodeName", nodeName);
     
    534534    value.set("useCapture", registeredEventListener.useCapture);
    535535    value.set("isAttribute", eventListener->isAttribute());
    536     value.set("nodeId", static_cast<long long>(pushNodePathToFrontend(node)));
     536    value.set("nodeId", pushNodePathToFrontend(node));
    537537    value.set("listener", getEventListenerHandlerBody(node->document(), m_frontend->scriptState(), eventListener.get()));
    538538    return value;
  • trunk/WebCore/inspector/InspectorFrontend.cpp

    r51245 r51439  
    106106}
    107107
    108 bool InspectorFrontend::addResource(long long identifier, const ScriptObject& resourceObj)
     108bool InspectorFrontend::addResource(unsigned long identifier, const ScriptObject& resourceObj)
    109109{
    110110    OwnPtr<ScriptFunctionCall> function(newFunctionCall("addResource"));
     
    116116}
    117117
    118 bool InspectorFrontend::updateResource(long long identifier, const ScriptObject& resourceObj)
     118bool InspectorFrontend::updateResource(unsigned long identifier, const ScriptObject& resourceObj)
    119119{
    120120    OwnPtr<ScriptFunctionCall> function(newFunctionCall("updateResource"));
     
    126126}
    127127
    128 void InspectorFrontend::removeResource(long long identifier)
     128void InspectorFrontend::removeResource(unsigned long identifier)
    129129{
    130130    OwnPtr<ScriptFunctionCall> function(newFunctionCall("removeResource"));
     
    133133}
    134134
    135 void InspectorFrontend::updateFocusedNode(long long nodeId)
     135void InspectorFrontend::updateFocusedNode(long nodeId)
    136136{
    137137    OwnPtr<ScriptFunctionCall> function(newFunctionCall("updateFocusedNode"));
  • trunk/WebCore/inspector/InspectorFrontend.h

    r51182 r51439  
    6868        void clearConsoleMessages();
    6969
    70         bool addResource(long long identifier, const ScriptObject& resourceObj);
    71         bool updateResource(long long identifier, const ScriptObject& resourceObj);
    72         void removeResource(long long identifier);
     70        bool addResource(unsigned long identifier, const ScriptObject& resourceObj);
     71        bool updateResource(unsigned long identifier, const ScriptObject& resourceObj);
     72        void removeResource(unsigned long identifier);
    7373
    74         void updateFocusedNode(long long nodeId);
     74        void updateFocusedNode(long nodeId);
    7575        void setAttachedWindow(bool attached);
    7676        void showPanel(int panel);
  • trunk/WebCore/inspector/InspectorResource.cpp

    r51422 r51439  
    4747namespace WebCore {
    4848
    49 InspectorResource::InspectorResource(long long identifier, DocumentLoader* loader)
     49InspectorResource::InspectorResource(unsigned long identifier, DocumentLoader* loader)
    5050    : m_identifier(identifier)
    5151    , m_loader(loader)
     
    7171}
    7272
    73 PassRefPtr<InspectorResource> InspectorResource::createCached(long long identifier, DocumentLoader* loader, const CachedResource* cachedResource)
     73PassRefPtr<InspectorResource> InspectorResource::createCached(unsigned long identifier, DocumentLoader* loader, const CachedResource* cachedResource)
    7474{
    7575    PassRefPtr<InspectorResource> resource = create(identifier, loader);
  • trunk/WebCore/inspector/InspectorResource.h

    r50905 r51439  
    6969        };
    7070
    71         static PassRefPtr<InspectorResource> create(long long identifier, DocumentLoader* loader)
     71        static PassRefPtr<InspectorResource> create(unsigned long identifier, DocumentLoader* loader)
    7272        {
    7373            return adoptRef(new InspectorResource(identifier, loader));
    7474        }
    7575
    76         static PassRefPtr<InspectorResource> createCached(long long identifier, DocumentLoader*, const CachedResource*);
     76        static PassRefPtr<InspectorResource> createCached(unsigned long identifier, DocumentLoader*, const CachedResource*);
    7777
    7878        ~InspectorResource();
     
    9292        bool isSameLoader(DocumentLoader* loader) const { return loader == m_loader; }
    9393        void markMainResource() { m_isMainResource = true; }
    94         long long identifier() const { return m_identifier; }
     94        unsigned long identifier() const { return m_identifier; }
    9595        String requestURL() const { return m_requestURL.string(); }
    9696        Frame* frame() const { return m_frame.get(); }
     
    146146        };
    147147
    148         InspectorResource(long long identifier, DocumentLoader*);
     148        InspectorResource(unsigned long identifier, DocumentLoader*);
    149149        Type type() const;
    150150
     
    152152        CachedResource* cachedResource() const;
    153153
    154         long long m_identifier;
     154        unsigned long m_identifier;
    155155        RefPtr<DocumentLoader> m_loader;
    156156        RefPtr<Frame> m_frame;
  • trunk/WebCore/inspector/TimelineRecordFactory.cpp

    r50524 r51439  
    124124    ScriptObject record = createGenericRecord(frontend, startTime);
    125125    ScriptObject data = frontend->newScriptObject();
    126     data.set("identifier", static_cast<long long>(identifier));
     126    data.set("identifier", identifier);
    127127    data.set("url", request.url().string());
    128128    data.set("requestMethod", request.httpMethod());
     
    137137    ScriptObject record = createGenericRecord(frontend, startTime);
    138138    ScriptObject data = frontend->newScriptObject();
    139     data.set("identifier", static_cast<long long>(identifier));
     139    data.set("identifier", identifier);
    140140    data.set("statusCode", response.httpStatusCode());
    141141    data.set("mimeType", response.mimeType());
     
    150150    ScriptObject record = createGenericRecord(frontend, startTime);
    151151    ScriptObject data = frontend->newScriptObject();
    152     data.set("identifier", static_cast<long long>(identifier));
     152    data.set("identifier", identifier);
    153153    data.set("didFail", didFail);
    154154    record.set("data", data);
Note: See TracChangeset for help on using the changeset viewer.