Changeset 91264 in webkit
- Timestamp:
- Jul 19, 2011 9:38:33 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r91259 r91264 1 2011-07-19 Vsevolod Vlasov <vsevik@chromium.org> 2 3 Web Inspector: Backend should provide network resource identifiers that are unique across navigation. 4 https://bugs.webkit.org/show_bug.cgi?id=64746 5 6 Reviewed by Pavel Feldman. 7 8 * inspector/timeline/timeline-network-resource-expected.txt: 9 * platform/chromium/inspector/timeline/timeline-network-resource-expected.txt: 10 1 11 2011-07-19 Jeremy Moskovich <jeremy@chromium.org> 2 12 -
trunk/LayoutTests/inspector/timeline/timeline-network-resource-expected.txt
r87395 r91264 8 8 startTime : <number> 9 9 data : { 10 identifier : < number>10 identifier : <string> 11 11 url : <string> 12 12 requestMethod : "GET" … … 21 21 startTime : <number> 22 22 data : { 23 identifier : < number>23 identifier : <string> 24 24 statusCode : 0 25 25 mimeType : <string> … … 36 36 startTime : <number> 37 37 data : { 38 identifier : < number>38 identifier : <string> 39 39 didFail : false 40 40 } -
trunk/LayoutTests/platform/chromium/inspector/timeline/timeline-network-resource-expected.txt
r87395 r91264 9 9 stackTrace : <object> 10 10 data : { 11 identifier : < number>11 identifier : <string> 12 12 url : <string> 13 13 requestMethod : "GET" … … 22 22 startTime : <number> 23 23 data : { 24 identifier : < number>24 identifier : <string> 25 25 statusCode : 0 26 26 mimeType : <string> … … 37 37 startTime : <number> 38 38 data : { 39 identifier : < number>39 identifier : <string> 40 40 didFail : false 41 41 } -
trunk/Source/WebCore/ChangeLog
r91263 r91264 1 2011-07-19 Vsevolod Vlasov <vsevik@chromium.org> 2 3 Web Inspector: Backend should provide network resource identifiers that are unique across navigation. 4 https://bugs.webkit.org/show_bug.cgi?id=64746 5 6 Reviewed by Pavel Feldman. 7 8 * inspector/ConsoleMessage.cpp: 9 (WebCore::ConsoleMessage::ConsoleMessage): 10 (WebCore::ConsoleMessage::addToFrontend): 11 * inspector/ConsoleMessage.h: 12 * inspector/IdentifiersFactory.cpp: 13 (WebCore::IdentifiersFactory::createIdentifier): 14 (WebCore::IdentifiersFactory::resourceId): 15 (WebCore::IdentifiersFactory::addProcessIdPrefixTo): 16 * inspector/IdentifiersFactory.h: 17 * inspector/Inspector.json: 18 * inspector/InspectorConsoleAgent.cpp: 19 (WebCore::InspectorConsoleAgent::didReceiveResponse): 20 (WebCore::InspectorConsoleAgent::didFailLoading): 21 * inspector/InspectorPageAgent.h: 22 * inspector/InspectorResourceAgent.cpp: 23 (WebCore::InspectorResourceAgent::willSendRequest): 24 (WebCore::InspectorResourceAgent::markResourceAsCached): 25 (WebCore::InspectorResourceAgent::didReceiveResponse): 26 (WebCore::InspectorResourceAgent::didReceiveData): 27 (WebCore::InspectorResourceAgent::didFinishLoading): 28 (WebCore::InspectorResourceAgent::didFailLoading): 29 (WebCore::InspectorResourceAgent::didLoadResourceFromMemoryCache): 30 (WebCore::InspectorResourceAgent::setInitialScriptContent): 31 (WebCore::InspectorResourceAgent::setInitialXHRContent): 32 (WebCore::InspectorResourceAgent::didReceiveXHRResponse): 33 (WebCore::InspectorResourceAgent::didCreateWebSocket): 34 (WebCore::InspectorResourceAgent::willSendWebSocketHandshakeRequest): 35 (WebCore::InspectorResourceAgent::didReceiveWebSocketHandshakeResponse): 36 (WebCore::InspectorResourceAgent::didCloseWebSocket): 37 (WebCore::InspectorResourceAgent::getResourceContent): 38 * inspector/InspectorResourceAgent.h: 39 * inspector/InspectorTimelineAgent.cpp: 40 (WebCore::InspectorTimelineAgent::willSendResourceRequest): 41 (WebCore::InspectorTimelineAgent::willReceiveResourceData): 42 (WebCore::InspectorTimelineAgent::willReceiveResourceResponse): 43 (WebCore::InspectorTimelineAgent::didFinishLoadingResource): 44 * inspector/NetworkResourcesData.cpp: 45 (WebCore::NetworkResourcesData::ResourceData::ResourceData): 46 (WebCore::NetworkResourcesData::resourceCreated): 47 (WebCore::NetworkResourcesData::responseReceived): 48 (WebCore::NetworkResourcesData::setResourceType): 49 (WebCore::NetworkResourcesData::resourceType): 50 (WebCore::NetworkResourcesData::setResourceContent): 51 (WebCore::NetworkResourcesData::maybeAddResourceData): 52 (WebCore::NetworkResourcesData::maybeDecodeDataToContent): 53 (WebCore::NetworkResourcesData::addCachedResource): 54 (WebCore::NetworkResourcesData::addResourceSharedBuffer): 55 (WebCore::NetworkResourcesData::data): 56 (WebCore::NetworkResourcesData::clear): 57 (WebCore::NetworkResourcesData::ensureNoDataForResourceId): 58 (WebCore::NetworkResourcesData::ensureFreeSpace): 59 * inspector/NetworkResourcesData.h: 60 (WebCore::NetworkResourcesData::ResourceData::resourceId): 61 * inspector/TimelineRecordFactory.cpp: 62 (WebCore::TimelineRecordFactory::createResourceSendRequestData): 63 (WebCore::TimelineRecordFactory::createResourceReceiveResponseData): 64 (WebCore::TimelineRecordFactory::createResourceFinishData): 65 (WebCore::TimelineRecordFactory::createReceiveResourceData): 66 * inspector/TimelineRecordFactory.h: 67 1 68 2011-07-19 Jessie Berlin <jberlin@apple.com> 2 69 -
trunk/Source/WebCore/inspector/ConsoleMessage.cpp
r89345 r91264 53 53 , m_url(u) 54 54 , m_repeatCount(1) 55 , m_requestId(0)56 55 { 57 56 } … … 67 66 , m_url() 68 67 , m_repeatCount(1) 69 , m_requestId(0) 70 { 71 } 72 73 ConsoleMessage::ConsoleMessage(MessageSource s, MessageType t, MessageLevel l, const String& m, const String& responseUrl, unsigned long identifier) 68 { 69 } 70 71 ConsoleMessage::ConsoleMessage(MessageSource s, MessageType t, MessageLevel l, const String& m, const String& responseUrl, const String& resourceId) 74 72 : m_source(s) 75 73 , m_type(t) … … 79 77 , m_url(responseUrl) 80 78 , m_repeatCount(1) 81 , m_requestId( identifier)79 , m_requestId(resourceId) 82 80 { 83 81 } … … 139 137 jsonObj->setString("text", m_message); 140 138 if (m_type == NetworkErrorMessageType) 141 jsonObj->set Number("networkIdentifier", m_requestId);139 jsonObj->setString("networkIdentifier", m_requestId); 142 140 if (m_arguments && m_arguments->argumentCount()) { 143 141 InjectedScript injectedScript = injectedScriptManager->injectedScriptFor(m_arguments->globalState()); -
trunk/Source/WebCore/inspector/ConsoleMessage.h
r89345 r91264 54 54 ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& m, unsigned li, const String& u); 55 55 ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& m, PassRefPtr<ScriptArguments>, PassRefPtr<ScriptCallStack>); 56 ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& m, const String& responseUrl, unsigned long identifier);56 ConsoleMessage(MessageSource, MessageType, MessageLevel, const String& m, const String& responseUrl, const String& resourceId); 57 57 ~ConsoleMessage(); 58 58 … … 78 78 String m_url; 79 79 unsigned m_repeatCount; 80 unsigned intm_requestId;80 String m_requestId; 81 81 }; 82 82 -
trunk/Source/WebCore/inspector/IdentifiersFactory.cpp
r91250 r91264 27 27 #include "IdentifiersFactory.h" 28 28 29 #include <wtf/text/StringBuilder.h> 30 29 31 #if ENABLE(INSPECTOR) 30 32 … … 43 45 String IdentifiersFactory::createIdentifier() 44 46 { 47 return addProcessIdPrefixTo(String::number(++s_lastUsedIdentifier)); 48 } 49 50 // static 51 String IdentifiersFactory::resourceId(unsigned long identifier) 52 { 53 return addProcessIdPrefixTo(String::number(identifier)); 54 } 55 56 // static 57 String IdentifiersFactory::addProcessIdPrefixTo(const String& id) 58 { 45 59 StringBuilder builder; 46 60 builder.append(String::number(s_processId)); 47 61 builder.append("."); 48 builder.append( String::number(++s_lastUsedIdentifier));62 builder.append(id); 49 63 return builder.toString(); 50 64 } -
trunk/Source/WebCore/inspector/IdentifiersFactory.h
r91250 r91264 37 37 static void setProcessId(long processId) { s_processId = processId; } 38 38 static String createIdentifier(); 39 static String resourceId(unsigned long identifier); 39 40 private: 41 static String addProcessIdPrefixTo(const String& id); 42 40 43 static long s_processId; 41 44 }; -
trunk/Source/WebCore/inspector/Inspector.json
r91176 r91264 495 495 "description": "Returns content of the given resource.", 496 496 "parameters": [ 497 { "name": "identifier", "type": " integer", "description": "Identifier of the resource to get content for." }497 { "name": "identifier", "type": "string", "description": "Identifier of the resource to get content for." } 498 498 ], 499 499 "returns": [ … … 516 516 "description": "Fired when page is about to send HTTP request.", 517 517 "parameters": [ 518 { "name": "identifier", "type": " integer", "description": "Request identifier." },518 { "name": "identifier", "type": "string", "description": "Request identifier." }, 519 519 { "name": "frameId", "type": "string", "description": "Frame identifier." }, 520 520 { "name": "loaderId", "type": "string", "description": "Loader identifier." }, … … 530 530 "description": "Fired when request is known to be served from disk cache.", 531 531 "parameters": [ 532 { "name": "identifier", "type": " integer", "description": "Request identifier." }532 { "name": "identifier", "type": "string", "description": "Request identifier." } 533 533 ] 534 534 }, … … 537 537 "description": "Fired when HTTP response is available.", 538 538 "parameters": [ 539 { "name": "identifier", "type": " integer", "description": "Request identifier." },539 { "name": "identifier", "type": "string", "description": "Request identifier." }, 540 540 { "name": "timestamp", "type": "number", "description": "Timestamp." }, 541 541 { "name": "type", "$ref": "Page.ResourceType", "description": "Resource type." }, … … 547 547 "description": "Fired when data chunk was received over the network.", 548 548 "parameters": [ 549 { "name": "identifier", "type": " integer", "description": "Request identifier." },549 { "name": "identifier", "type": "string", "description": "Request identifier." }, 550 550 { "name": "timestamp", "type": "number", "description": "Timestamp." }, 551 551 { "name": "dataLength", "type": "integer", "description": "Data chunk length." }, … … 557 557 "description": "Fired when HTTP request has finished loading.", 558 558 "parameters": [ 559 { "name": "identifier", "type": " integer", "description": "Request identifier." },559 { "name": "identifier", "type": "string", "description": "Request identifier." }, 560 560 { "name": "timestamp", "type": "number", "description": "Timestamp." } 561 561 ] … … 565 565 "description": "Fired when HTTP request has failed to load.", 566 566 "parameters": [ 567 { "name": "identifier", "type": " integer", "description": "Request identifier." },567 { "name": "identifier", "type": "string", "description": "Request identifier." }, 568 568 { "name": "timestamp", "type": "number", "description": "Timestamp." }, 569 569 { "name": "errorText", "type": "string", "description": "User friendly error message." }, … … 575 575 "description": "Fired when HTTP request has been served from memory cache.", 576 576 "parameters": [ 577 { "name": "identifier", "type": " integer", "description": "Request identifier." },577 { "name": "identifier", "type": "string", "description": "Request identifier." }, 578 578 { "name": "frameId", "type": "string", "description": "Frame identifier." }, 579 579 { "name": "loaderId", "type": "string", "description": "Loader identifier." }, … … 587 587 "description": "Fired for worker scripts when their content becomes available.", 588 588 "parameters": [ 589 { "name": "identifier", "type": " integer", "description": "Request identifier." },589 { "name": "identifier", "type": "string", "description": "Request identifier." }, 590 590 { "name": "content", "type": "string", "description": "Resource content." }, 591 591 { "name": "type", "$ref": "Page.ResourceType", "description": "Resource type." } … … 596 596 "description": "Fired when WebSocket is about to initiate handshake.", 597 597 "parameters": [ 598 { "name": "identifier", "type": " integer", "description": "Request identifier." },598 { "name": "identifier", "type": "string", "description": "Request identifier." }, 599 599 { "name": "timestamp", "type": "number", "description": "Timestamp." }, 600 600 { "name": "request", "type": "object", "description": "WebSocket request data." } … … 605 605 "description": "Fired when WebSocket handshake response becomes available.", 606 606 "parameters": [ 607 { "name": "identifier", "type": " integer", "description": "Request identifier." },607 { "name": "identifier", "type": "string", "description": "Request identifier." }, 608 608 { "name": "timestamp", "type": "number", "description": "Timestamp." }, 609 609 { "name": "response", "type": "object", "description": "WebSocket response data." } … … 614 614 "description": "Fired upon WebSocket creation.", 615 615 "parameters": [ 616 { "name": "identifier", "type": " integer", "description": "Request identifier." },616 { "name": "identifier", "type": "string", "description": "Request identifier." }, 617 617 { "name": "url", "type": "string", "description": "WebSocket request URL." } 618 618 ] … … 622 622 "description": "Fired when WebSocket is closed.", 623 623 "parameters": [ 624 { "name": "identifier", "type": " integer", "description": "Request identifier." },624 { "name": "identifier", "type": "string", "description": "Request identifier." }, 625 625 { "name": "timestamp", "type": "number", "description": "Timestamp." } 626 626 ] -
trunk/Source/WebCore/inspector/InspectorConsoleAgent.cpp
r89912 r91264 32 32 #include "ConsoleMessage.h" 33 33 #include "DOMWindow.h" 34 #include "IdentifiersFactory.h" 34 35 #include "InjectedScriptHost.h" 35 36 #include "InjectedScriptManager.h" … … 226 227 if (response.httpStatusCode() >= 400) { 227 228 String message = "Failed to load resource: the server responded with a status of " + String::number(response.httpStatusCode()) + " (" + response.httpStatusText() + ')'; 228 addConsoleMessage(adoptPtr(new ConsoleMessage(OtherMessageSource, NetworkErrorMessageType, ErrorMessageLevel, message, response.url().string(), identifier))); 229 String resourceId = IdentifiersFactory::resourceId(identifier); 230 addConsoleMessage(adoptPtr(new ConsoleMessage(OtherMessageSource, NetworkErrorMessageType, ErrorMessageLevel, message, response.url().string(), resourceId))); 229 231 } 230 232 } … … 239 241 if (!error.localizedDescription().isEmpty()) 240 242 message += ": " + error.localizedDescription(); 241 addConsoleMessage(adoptPtr(new ConsoleMessage(OtherMessageSource, NetworkErrorMessageType, ErrorMessageLevel, message, error.failingURL(), identifier))); 243 String resourceId = IdentifiersFactory::resourceId(identifier); 244 addConsoleMessage(adoptPtr(new ConsoleMessage(OtherMessageSource, NetworkErrorMessageType, ErrorMessageLevel, message, error.failingURL(), resourceId))); 242 245 } 243 246 -
trunk/Source/WebCore/inspector/InspectorPageAgent.h
r91250 r91264 112 112 // Cross-agents API 113 113 Frame* mainFrame(); 114 String createIdentifier(); 114 115 Frame* frameForId(const String& frameId); 115 116 String frameId(Frame*); -
trunk/Source/WebCore/inspector/InspectorResourceAgent.cpp
r91006 r91264 42 42 #include "FrameLoader.h" 43 43 #include "HTTPHeaderMap.h" 44 #include "IdentifiersFactory.h" 44 45 #include "InspectorClient.h" 45 46 #include "InspectorFrontend.h" … … 200 201 void InspectorResourceAgent::willSendRequest(unsigned long identifier, DocumentLoader* loader, ResourceRequest& request, const ResourceResponse& redirectResponse) 201 202 { 202 m_resourcesData->resourceCreated(identifier, m_pageAgent->loaderId(loader)); 203 String resourceId = IdentifiersFactory::resourceId(identifier); 204 m_resourcesData->resourceCreated(resourceId, m_pageAgent->loaderId(loader)); 203 205 204 206 RefPtr<InspectorObject> headers = m_state->getObject(ResourceAgentState::extraRequestHeaders); … … 222 224 else 223 225 callStackValue = InspectorArray::create(); 224 m_frontend->requestWillBeSent( static_cast<int>(identifier), m_pageAgent->frameId(loader->frame()), m_pageAgent->loaderId(loader), loader->url().string(), buildObjectForResourceRequest(request), currentTime(), callStackValue, buildObjectForResourceResponse(redirectResponse));226 m_frontend->requestWillBeSent(resourceId, m_pageAgent->frameId(loader->frame()), m_pageAgent->loaderId(loader), loader->url().string(), buildObjectForResourceRequest(request), currentTime(), callStackValue, buildObjectForResourceResponse(redirectResponse)); 225 227 } 226 228 227 229 void InspectorResourceAgent::markResourceAsCached(unsigned long identifier) 228 230 { 229 m_frontend->resourceMarkedAsCached( static_cast<int>(identifier));231 m_frontend->resourceMarkedAsCached(IdentifiersFactory::resourceId(identifier)); 230 232 } 231 233 232 234 void InspectorResourceAgent::didReceiveResponse(unsigned long identifier, DocumentLoader* loader, const ResourceResponse& response) 233 235 { 236 String resourceId = IdentifiersFactory::resourceId(identifier); 234 237 RefPtr<InspectorObject> resourceResponse = buildObjectForResourceResponse(response); 235 238 InspectorPageAgent::ResourceType type = InspectorPageAgent::OtherResource; … … 245 248 resourceResponse->setString("mimeType", cachedResource->response().mimeType()); 246 249 247 m_resourcesData->addCachedResource( identifier, cachedResource);250 m_resourcesData->addCachedResource(resourceId, cachedResource); 248 251 } 249 252 if (equalIgnoringFragmentIdentifier(response.url(), loader->frameLoader()->icon()->url())) … … 251 254 else if (equalIgnoringFragmentIdentifier(response.url(), loader->url()) && type == InspectorPageAgent::OtherResource) 252 255 type = InspectorPageAgent::DocumentResource; 253 else if (m_loadingXHRSynchronously || m_resourcesData->resourceType( identifier) == InspectorPageAgent::XHRResource)256 else if (m_loadingXHRSynchronously || m_resourcesData->resourceType(resourceId) == InspectorPageAgent::XHRResource) 254 257 type = InspectorPageAgent::XHRResource; 255 258 256 m_resourcesData->responseReceived( identifier, m_pageAgent->frameId(loader->frame()), response);257 } 258 m_resourcesData->setResourceType( identifier, type);259 m_frontend->responseReceived( static_cast<int>(identifier), currentTime(), InspectorPageAgent::resourceTypeString(type), resourceResponse);259 m_resourcesData->responseReceived(resourceId, m_pageAgent->frameId(loader->frame()), response); 260 } 261 m_resourcesData->setResourceType(resourceId, type); 262 m_frontend->responseReceived(resourceId, currentTime(), InspectorPageAgent::resourceTypeString(type), resourceResponse); 260 263 // If we revalidated the resource and got Not modified, send content length following didReceiveResponse 261 264 // as there will be no calls to didReceiveData from the network stack. … … 266 269 void InspectorResourceAgent::didReceiveData(unsigned long identifier, const char* data, int dataLength, int encodedDataLength) 267 270 { 268 if (data && m_resourcesData->resourceType(identifier) == InspectorPageAgent::OtherResource) 269 m_resourcesData->maybeAddResourceData(identifier, data, dataLength); 270 271 m_frontend->dataReceived(static_cast<int>(identifier), currentTime(), dataLength, encodedDataLength); 271 String resourceId = IdentifiersFactory::resourceId(identifier); 272 if (data && m_resourcesData->resourceType(resourceId) == InspectorPageAgent::OtherResource) 273 m_resourcesData->maybeAddResourceData(resourceId, data, dataLength); 274 275 m_frontend->dataReceived(resourceId, currentTime(), dataLength, encodedDataLength); 272 276 } 273 277 274 278 void InspectorResourceAgent::didFinishLoading(unsigned long identifier, DocumentLoader* loader, double finishTime) 275 279 { 276 if (m_resourcesData->resourceType(identifier) == InspectorPageAgent::DocumentResource) 277 m_resourcesData->addResourceSharedBuffer(identifier, loader->frameLoader()->documentLoader()->mainResourceData(), loader->frame()->document()->inputEncoding()); 278 279 m_resourcesData->maybeDecodeDataToContent(identifier); 280 String resourceId = IdentifiersFactory::resourceId(identifier); 281 if (m_resourcesData->resourceType(resourceId) == InspectorPageAgent::DocumentResource) 282 m_resourcesData->addResourceSharedBuffer(resourceId, loader->frameLoader()->documentLoader()->mainResourceData(), loader->frame()->document()->inputEncoding()); 283 284 m_resourcesData->maybeDecodeDataToContent(resourceId); 280 285 281 286 if (!finishTime) 282 287 finishTime = currentTime(); 283 288 284 m_frontend->loadingFinished( static_cast<int>(identifier), finishTime);289 m_frontend->loadingFinished(resourceId, finishTime); 285 290 } 286 291 287 292 void InspectorResourceAgent::didFailLoading(unsigned long identifier, DocumentLoader* loader, const ResourceError& error) 288 293 { 289 if (m_resourcesData->resourceType(identifier) == InspectorPageAgent::DocumentResource) 290 m_resourcesData->addResourceSharedBuffer(identifier, loader->frameLoader()->documentLoader()->mainResourceData(), loader->frame()->document()->inputEncoding()); 291 292 m_frontend->loadingFailed(static_cast<int>(identifier), currentTime(), error.localizedDescription(), error.isCancellation()); 294 String resourceId = IdentifiersFactory::resourceId(identifier); 295 if (m_resourcesData->resourceType(resourceId) == InspectorPageAgent::DocumentResource) 296 m_resourcesData->addResourceSharedBuffer(resourceId, loader->frameLoader()->documentLoader()->mainResourceData(), loader->frame()->document()->inputEncoding()); 297 298 m_frontend->loadingFailed(resourceId, currentTime(), error.localizedDescription(), error.isCancellation()); 293 299 } 294 300 … … 298 304 String frameId = m_pageAgent->frameId(loader->frame()); 299 305 unsigned long identifier = loader->frame()->page()->progress()->createUniqueIdentifier(); 300 m_resourcesData->resourceCreated(identifier, loaderId); 301 m_resourcesData->addCachedResource(identifier, resource); 302 303 m_frontend->resourceLoadedFromMemoryCache(static_cast<int>(identifier), frameId, loaderId, loader->url().string(), currentTime(), buildObjectForCachedResource(*resource)); 306 String resourceId = IdentifiersFactory::resourceId(identifier); 307 m_resourcesData->resourceCreated(resourceId, loaderId); 308 m_resourcesData->addCachedResource(resourceId, resource); 309 310 m_frontend->resourceLoadedFromMemoryCache(resourceId, frameId, loaderId, loader->url().string(), currentTime(), buildObjectForCachedResource(*resource)); 304 311 } 305 312 306 313 void InspectorResourceAgent::setInitialScriptContent(unsigned long identifier, const String& sourceString) 307 314 { 308 m_frontend->initialContentSet( static_cast<int>(identifier), sourceString, InspectorPageAgent::resourceTypeString(InspectorPageAgent::ScriptResource));315 m_frontend->initialContentSet(IdentifiersFactory::resourceId(identifier), sourceString, InspectorPageAgent::resourceTypeString(InspectorPageAgent::ScriptResource)); 309 316 } 310 317 311 318 void InspectorResourceAgent::setInitialXHRContent(unsigned long identifier, const String& sourceString) 312 319 { 313 m_resourcesData->setResourceContent( identifier, sourceString);320 m_resourcesData->setResourceContent(IdentifiersFactory::resourceId(identifier), sourceString); 314 321 } 315 322 316 323 void InspectorResourceAgent::didReceiveXHRResponse(unsigned long identifier) 317 324 { 318 m_resourcesData->setResourceType( identifier, InspectorPageAgent::XHRResource);325 m_resourcesData->setResourceType(IdentifiersFactory::resourceId(identifier), InspectorPageAgent::XHRResource); 319 326 } 320 327 … … 354 361 void InspectorResourceAgent::didCreateWebSocket(unsigned long identifier, const KURL& requestURL) 355 362 { 356 m_frontend->webSocketCreated( static_cast<int>(identifier), requestURL.string());363 m_frontend->webSocketCreated(IdentifiersFactory::resourceId(identifier), requestURL.string()); 357 364 } 358 365 … … 362 369 requestObject->setObject("headers", buildObjectForHeaders(request.headerFields())); 363 370 requestObject->setString("requestKey3", createReadableStringFromBinary(request.key3().value, sizeof(request.key3().value))); 364 m_frontend->webSocketWillSendHandshakeRequest( static_cast<int>(identifier), currentTime(), requestObject);371 m_frontend->webSocketWillSendHandshakeRequest(IdentifiersFactory::resourceId(identifier), currentTime(), requestObject); 365 372 } 366 373 … … 372 379 responseObject->setObject("headers", buildObjectForHeaders(response.headerFields())); 373 380 responseObject->setString("challengeResponse", createReadableStringFromBinary(response.challengeResponse().value, sizeof(response.challengeResponse().value))); 374 m_frontend->webSocketHandshakeResponseReceived( static_cast<int>(identifier), currentTime(), responseObject);381 m_frontend->webSocketHandshakeResponseReceived(IdentifiersFactory::resourceId(identifier), currentTime(), responseObject); 375 382 } 376 383 377 384 void InspectorResourceAgent::didCloseWebSocket(unsigned long identifier) 378 385 { 379 m_frontend->webSocketClosed( static_cast<int>(identifier), currentTime());386 m_frontend->webSocketClosed(IdentifiersFactory::resourceId(identifier), currentTime()); 380 387 } 381 388 #endif // ENABLE(WEB_SOCKETS) … … 455 462 } 456 463 457 void InspectorResourceAgent::getResourceContent(ErrorString* errorString, unsigned long identifier, String* content, bool* base64Encoded)458 { 459 NetworkResourcesData::ResourceData const* resourceData = m_resourcesData->data( identifier);464 void InspectorResourceAgent::getResourceContent(ErrorString* errorString, const String& resourceId, String* content, bool* base64Encoded) 465 { 466 NetworkResourcesData::ResourceData const* resourceData = m_resourcesData->data(resourceId); 460 467 if (!resourceData) { 461 468 *errorString = "No resource with given identifier found"; -
trunk/Source/WebCore/inspector/InspectorResourceAgent.h
r91006 r91264 123 123 void setUserAgentOverride(ErrorString*, const String& userAgent); 124 124 void setExtraHeaders(ErrorString*, PassRefPtr<InspectorObject>); 125 void getResourceContent(ErrorString*, unsigned long identifier, String* content, bool* base64Encoded);125 void getResourceContent(ErrorString*, const String& resourceId, String* content, bool* base64Encoded); 126 126 void clearCache(ErrorString*, const String* const optionalPreservedLoaderId); 127 127 -
trunk/Source/WebCore/inspector/InspectorTimelineAgent.cpp
r91061 r91264 35 35 36 36 #include "Event.h" 37 #include "IdentifiersFactory.h" 37 38 #include "InspectorFrontend.h" 38 39 #include "InspectorState.h" … … 291 292 pushGCEventRecords(); 292 293 RefPtr<InspectorObject> record = TimelineRecordFactory::createGenericRecord(WTF::currentTimeMS()); 293 record->setObject("data", TimelineRecordFactory::createResourceSendRequestData(identifier, request)); 294 String resourceId = IdentifiersFactory::resourceId(identifier); 295 record->setObject("data", TimelineRecordFactory::createResourceSendRequestData(resourceId, request)); 294 296 record->setString("type", TimelineRecordType::ResourceSendRequest); 295 297 setHeapSizeStatistic(record.get()); … … 299 301 void InspectorTimelineAgent::willReceiveResourceData(unsigned long identifier) 300 302 { 301 pushCurrentRecord(TimelineRecordFactory::createReceiveResourceData(identifier), TimelineRecordType::ResourceReceivedData); 303 String resourceId = IdentifiersFactory::resourceId(identifier); 304 pushCurrentRecord(TimelineRecordFactory::createReceiveResourceData(resourceId), TimelineRecordType::ResourceReceivedData); 302 305 } 303 306 … … 309 312 void InspectorTimelineAgent::willReceiveResourceResponse(unsigned long identifier, const ResourceResponse& response) 310 313 { 311 pushCurrentRecord(TimelineRecordFactory::createResourceReceiveResponseData(identifier, response), TimelineRecordType::ResourceReceiveResponse); 314 String resourceId = IdentifiersFactory::resourceId(identifier); 315 pushCurrentRecord(TimelineRecordFactory::createResourceReceiveResponseData(resourceId, response), TimelineRecordType::ResourceReceiveResponse); 312 316 } 313 317 … … 322 326 // Sometimes network stack can provide for us exact finish loading time. In the other case we will use currentTime. 323 327 RefPtr<InspectorObject> record = TimelineRecordFactory::createGenericRecord(WTF::currentTimeMS()); 324 record->setObject("data", TimelineRecordFactory::createResourceFinishData(identifier, didFail, finishTime * 1000)); 328 String resourceId = IdentifiersFactory::resourceId(identifier); 329 record->setObject("data", TimelineRecordFactory::createResourceFinishData(resourceId, didFail, finishTime * 1000)); 325 330 record->setString("type", TimelineRecordType::ResourceFinish); 326 331 setHeapSizeStatistic(record.get()); -
trunk/Source/WebCore/inspector/NetworkResourcesData.cpp
r90389 r91264 48 48 49 49 // ResourceData 50 NetworkResourcesData::ResourceData::ResourceData( unsigned long identifier, const String& loaderId)51 : m_ identifier(identifier)50 NetworkResourcesData::ResourceData::ResourceData(const String& resourceId, const String& loaderId) 51 : m_resourceId(resourceId) 52 52 , m_loaderId(loaderId) 53 53 , m_isContentPurged(false) … … 131 131 } 132 132 133 void NetworkResourcesData::resourceCreated( unsigned long identifier, const String& loaderId)134 { 135 ensureNoDataFor Identifier(identifier);136 m_ identifierToResourceDataMap.set(identifier, new ResourceData(identifier, loaderId));137 } 138 139 void NetworkResourcesData::responseReceived( unsigned long identifier, const String& frameId, const ResourceResponse& response)140 { 141 ResourceData* resourceData = m_ identifierToResourceDataMap.get(identifier);133 void NetworkResourcesData::resourceCreated(const String& resourceId, const String& loaderId) 134 { 135 ensureNoDataForResourceId(resourceId); 136 m_resourceIdToResourceDataMap.set(resourceId, new ResourceData(resourceId, loaderId)); 137 } 138 139 void NetworkResourcesData::responseReceived(const String& resourceId, const String& frameId, const ResourceResponse& response) 140 { 141 ResourceData* resourceData = m_resourceIdToResourceDataMap.get(resourceId); 142 142 if (!resourceData) 143 143 return; … … 147 147 } 148 148 149 void NetworkResourcesData::setResourceType( unsigned long identifier, InspectorPageAgent::ResourceType type)150 { 151 ResourceData* resourceData = m_ identifierToResourceDataMap.get(identifier);149 void NetworkResourcesData::setResourceType(const String& resourceId, InspectorPageAgent::ResourceType type) 150 { 151 ResourceData* resourceData = m_resourceIdToResourceDataMap.get(resourceId); 152 152 if (!resourceData) 153 153 return; … … 155 155 } 156 156 157 InspectorPageAgent::ResourceType NetworkResourcesData::resourceType( unsigned long identifier)158 { 159 ResourceData* resourceData = m_ identifierToResourceDataMap.get(identifier);157 InspectorPageAgent::ResourceType NetworkResourcesData::resourceType(const String& resourceId) 158 { 159 ResourceData* resourceData = m_resourceIdToResourceDataMap.get(resourceId); 160 160 if (!resourceData) 161 161 return InspectorPageAgent::OtherResource; … … 163 163 } 164 164 165 void NetworkResourcesData::setResourceContent( unsigned long identifier, const String& content)166 { 167 ResourceData* resourceData = m_ identifierToResourceDataMap.get(identifier);165 void NetworkResourcesData::setResourceContent(const String& resourceId, const String& content) 166 { 167 ResourceData* resourceData = m_resourceIdToResourceDataMap.get(resourceId); 168 168 if (!resourceData) 169 169 return; … … 174 174 return; 175 175 if (ensureFreeSpace(dataLength) && !resourceData->isContentPurged()) { 176 m_ identifiersDeque.append(identifier);176 m_resourceIdsDeque.append(resourceId); 177 177 resourceData->setContent(content); 178 178 m_contentSize += dataLength; … … 180 180 } 181 181 182 void NetworkResourcesData::maybeAddResourceData( unsigned long identifier, const char* data, int dataLength)183 { 184 ResourceData* resourceData = m_ identifierToResourceDataMap.get(identifier);182 void NetworkResourcesData::maybeAddResourceData(const String& resourceId, const char* data, int dataLength) 183 { 184 ResourceData* resourceData = m_resourceIdToResourceDataMap.get(resourceId); 185 185 if (!resourceData) 186 186 return; … … 192 192 return; 193 193 if (ensureFreeSpace(dataLength) && !resourceData->isContentPurged()) { 194 m_ identifiersDeque.append(identifier);194 m_resourceIdsDeque.append(resourceId); 195 195 resourceData->appendData(data, dataLength); 196 196 m_contentSize += dataLength; … … 198 198 } 199 199 200 void NetworkResourcesData::maybeDecodeDataToContent( unsigned long identifier)201 { 202 ResourceData* resourceData = m_ identifierToResourceDataMap.get(identifier);200 void NetworkResourcesData::maybeDecodeDataToContent(const String& resourceId) 201 { 202 ResourceData* resourceData = m_resourceIdToResourceDataMap.get(resourceId); 203 203 if (!resourceData) 204 204 return; … … 211 211 } 212 212 213 void NetworkResourcesData::addCachedResource( unsigned long identifier, CachedResource* cachedResource)214 { 215 if (!m_ identifierToResourceDataMap.contains(identifier))216 return; 217 ResourceData* resourceData = m_ identifierToResourceDataMap.get(identifier);213 void NetworkResourcesData::addCachedResource(const String& resourceId, CachedResource* cachedResource) 214 { 215 if (!m_resourceIdToResourceDataMap.contains(resourceId)) 216 return; 217 ResourceData* resourceData = m_resourceIdToResourceDataMap.get(resourceId); 218 218 219 219 resourceData->setCachedResource(cachedResource); 220 220 } 221 221 222 void NetworkResourcesData::addResourceSharedBuffer( unsigned long identifier, PassRefPtr<SharedBuffer> buffer, const String& textEncodingName)223 { 224 ResourceData* resourceData = m_ identifierToResourceDataMap.get(identifier);222 void NetworkResourcesData::addResourceSharedBuffer(const String& resourceId, PassRefPtr<SharedBuffer> buffer, const String& textEncodingName) 223 { 224 ResourceData* resourceData = m_resourceIdToResourceDataMap.get(resourceId); 225 225 if (!resourceData) 226 226 return; … … 229 229 } 230 230 231 NetworkResourcesData::ResourceData const* NetworkResourcesData::data( unsigned long identifier)232 { 233 return m_ identifierToResourceDataMap.get(identifier);231 NetworkResourcesData::ResourceData const* NetworkResourcesData::data(const String& resourceId) 232 { 233 return m_resourceIdToResourceDataMap.get(resourceId); 234 234 } 235 235 236 236 void NetworkResourcesData::clear(const String& preservedLoaderId) 237 237 { 238 m_ identifiersDeque.clear();238 m_resourceIdsDeque.clear(); 239 239 m_contentSize = 0; 240 240 … … 242 242 243 243 ResourceDataMap::iterator it; 244 ResourceDataMap::iterator end = m_ identifierToResourceDataMap.end();245 for (it = m_ identifierToResourceDataMap.begin(); it != end; ++it) {244 ResourceDataMap::iterator end = m_resourceIdToResourceDataMap.end(); 245 for (it = m_resourceIdToResourceDataMap.begin(); it != end; ++it) { 246 246 ResourceData* resourceData = it->second; 247 247 if (!preservedLoaderId.isNull() && resourceData->loaderId() == preservedLoaderId) … … 250 250 delete resourceData; 251 251 } 252 m_ identifierToResourceDataMap.swap(preservedMap);252 m_resourceIdToResourceDataMap.swap(preservedMap); 253 253 } 254 254 … … 261 261 262 262 263 void NetworkResourcesData::ensureNoDataFor Identifier(unsigned long identifier)264 { 265 ResourceData* resourceData = m_ identifierToResourceDataMap.get(identifier);263 void NetworkResourcesData::ensureNoDataForResourceId(const String& resourceId) 264 { 265 ResourceData* resourceData = m_resourceIdToResourceDataMap.get(resourceId); 266 266 if (resourceData) { 267 267 if (resourceData->hasContent() || resourceData->hasData()) 268 268 m_contentSize -= resourceData->purgeContent(); 269 269 delete resourceData; 270 m_ identifierToResourceDataMap.remove(identifier);270 m_resourceIdToResourceDataMap.remove(resourceId); 271 271 } 272 272 } … … 278 278 279 279 while (size > m_maximumResourcesContentSize - m_contentSize) { 280 unsigned long identifier = m_identifiersDeque.takeFirst();281 ResourceData* resourceData = m_ identifierToResourceDataMap.get(identifier);280 String resourceId = m_resourceIdsDeque.takeFirst(); 281 ResourceData* resourceData = m_resourceIdToResourceDataMap.get(resourceId); 282 282 if (resourceData) 283 283 m_contentSize -= resourceData->purgeContent(); -
trunk/Source/WebCore/inspector/NetworkResourcesData.h
r90389 r91264 52 52 friend class NetworkResourcesData; 53 53 public: 54 ResourceData( unsigned long identifier, const String& loaderId);54 ResourceData(const String& resourceId, const String& loaderId); 55 55 56 unsigned long identifier() const { return m_identifier; }56 String resourceId() const { return m_resourceId; } 57 57 String loaderId() const { return m_loaderId; } 58 58 … … 91 91 int decodeDataToContent(); 92 92 93 unsigned long m_identifier;93 String m_resourceId; 94 94 String m_loaderId; 95 95 String m_frameId; … … 111 111 ~NetworkResourcesData(); 112 112 113 void resourceCreated( unsigned long identifier, const String& loaderId);114 void responseReceived( unsigned long identifier, const String& frameId, const ResourceResponse&);115 void setResourceType( unsigned long identifier, InspectorPageAgent::ResourceType);116 InspectorPageAgent::ResourceType resourceType( unsigned long identifier);117 void setResourceContent( unsigned long identifier, const String& content);118 void maybeAddResourceData( unsigned long identifier, const char* data, int dataLength);119 void maybeDecodeDataToContent( unsigned long identifier);120 void addCachedResource( unsigned long identifier, CachedResource*);121 void addResourceSharedBuffer( unsigned long identifier, PassRefPtr<SharedBuffer>, const String& textEncodingName);122 ResourceData const* data( unsigned long identifier);113 void resourceCreated(const String& resourceId, const String& loaderId); 114 void responseReceived(const String& resourceId, const String& frameId, const ResourceResponse&); 115 void setResourceType(const String& resourceId, InspectorPageAgent::ResourceType); 116 InspectorPageAgent::ResourceType resourceType(const String& resourceId); 117 void setResourceContent(const String& resourceId, const String& content); 118 void maybeAddResourceData(const String& resourceId, const char* data, int dataLength); 119 void maybeDecodeDataToContent(const String& resourceId); 120 void addCachedResource(const String& resourceId, CachedResource*); 121 void addResourceSharedBuffer(const String& resourceId, PassRefPtr<SharedBuffer>, const String& textEncodingName); 122 ResourceData const* data(const String& resourceId); 123 123 void clear(const String& preservedLoaderId = String()); 124 124 … … 126 126 127 127 private: 128 void ensureNoDataFor Identifier(unsigned long identifier);128 void ensureNoDataForResourceId(const String& resourceId); 129 129 bool ensureFreeSpace(int size); 130 130 131 Deque< unsigned long> m_identifiersDeque;131 Deque<String> m_resourceIdsDeque; 132 132 133 typedef HashMap< unsigned long, ResourceData*> ResourceDataMap;134 ResourceDataMap m_ identifierToResourceDataMap;133 typedef HashMap<String, ResourceData*> ResourceDataMap; 134 ResourceDataMap m_resourceIdToResourceDataMap; 135 135 int m_contentSize; 136 136 int m_maximumResourcesContentSize; -
trunk/Source/WebCore/inspector/TimelineRecordFactory.cpp
r91061 r91264 130 130 } 131 131 132 PassRefPtr<InspectorObject> TimelineRecordFactory::createResourceSendRequestData( unsigned long identifier, const ResourceRequest& request)132 PassRefPtr<InspectorObject> TimelineRecordFactory::createResourceSendRequestData(const String& resourceId, const ResourceRequest& request) 133 133 { 134 134 RefPtr<InspectorObject> data = InspectorObject::create(); 135 data->set Number("identifier", identifier);135 data->setString("identifier", resourceId); 136 136 data->setString("url", request.url().string()); 137 137 data->setString("requestMethod", request.httpMethod()); … … 139 139 } 140 140 141 PassRefPtr<InspectorObject> TimelineRecordFactory::createResourceReceiveResponseData( unsigned long identifier, const ResourceResponse& response)141 PassRefPtr<InspectorObject> TimelineRecordFactory::createResourceReceiveResponseData(const String& resourceId, const ResourceResponse& response) 142 142 { 143 143 RefPtr<InspectorObject> data = InspectorObject::create(); 144 data->set Number("identifier", identifier);144 data->setString("identifier", resourceId); 145 145 data->setNumber("statusCode", response.httpStatusCode()); 146 146 data->setString("mimeType", response.mimeType()); … … 148 148 } 149 149 150 PassRefPtr<InspectorObject> TimelineRecordFactory::createResourceFinishData( unsigned long identifier, bool didFail, double finishTime)150 PassRefPtr<InspectorObject> TimelineRecordFactory::createResourceFinishData(const String& resourceId, bool didFail, double finishTime) 151 151 { 152 152 RefPtr<InspectorObject> data = InspectorObject::create(); 153 data->set Number("identifier", identifier);153 data->setString("identifier", resourceId); 154 154 data->setBoolean("didFail", didFail); 155 155 if (finishTime) … … 158 158 } 159 159 160 PassRefPtr<InspectorObject> TimelineRecordFactory::createReceiveResourceData( unsigned long identifier)160 PassRefPtr<InspectorObject> TimelineRecordFactory::createReceiveResourceData(const String& resourceId) 161 161 { 162 162 RefPtr<InspectorObject> data = InspectorObject::create(); 163 data->set Number("identifier", identifier);163 data->setString("identifier", resourceId); 164 164 return data.release(); 165 165 } -
trunk/Source/WebCore/inspector/TimelineRecordFactory.h
r91061 r91264 65 65 static PassRefPtr<InspectorObject> createTimeStampData(const String&); 66 66 67 static PassRefPtr<InspectorObject> createResourceSendRequestData( unsigned long identifier, const ResourceRequest&);67 static PassRefPtr<InspectorObject> createResourceSendRequestData(const String& resourceId, const ResourceRequest&); 68 68 69 69 static PassRefPtr<InspectorObject> createScheduleResourceRequestData(const String&); 70 70 71 static PassRefPtr<InspectorObject> createResourceReceiveResponseData( unsigned long identifier, const ResourceResponse&);71 static PassRefPtr<InspectorObject> createResourceReceiveResponseData(const String& resourceId, const ResourceResponse&); 72 72 73 static PassRefPtr<InspectorObject> createReceiveResourceData( unsigned long identifier);73 static PassRefPtr<InspectorObject> createReceiveResourceData(const String& resourceId); 74 74 75 static PassRefPtr<InspectorObject> createResourceFinishData( unsigned long identifier, bool didFail, double finishTime);75 static PassRefPtr<InspectorObject> createResourceFinishData(const String& resourceId, bool didFail, double finishTime); 76 76 77 77 static PassRefPtr<InspectorObject> createPaintData(const IntRect&);
Note: See TracChangeset
for help on using the changeset viewer.