Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(146)

Side by Side Diff: third_party/WebKit/Source/core/fetch/ScriptResource.cpp

Issue 1369253002: Add Web Resources usage to chrome://tracing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@web_cache2_base
Patch Set: Nits/. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de) 2 Copyright (C) 1998 Lars Knoll (knoll@mpi-hd.mpg.de)
3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org) 3 Copyright (C) 2001 Dirk Mueller (mueller@kde.org)
4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org) 4 Copyright (C) 2002 Waldo Bastian (bastian@kde.org)
5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com) 5 Copyright (C) 2006 Samuel Weinig (sam.weinig@gmail.com)
6 Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. 6 Copyright (C) 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved.
7 7
8 This library is free software; you can redistribute it and/or 8 This library is free software; you can redistribute it and/or
9 modify it under the terms of the GNU Library General Public 9 modify it under the terms of the GNU Library General Public
10 License as published by the Free Software Foundation; either 10 License as published by the Free Software Foundation; either
(...skipping 15 matching lines...) Expand all
26 26
27 #include "config.h" 27 #include "config.h"
28 #include "core/fetch/ScriptResource.h" 28 #include "core/fetch/ScriptResource.h"
29 29
30 #include "core/fetch/FetchRequest.h" 30 #include "core/fetch/FetchRequest.h"
31 #include "core/fetch/ResourceClientWalker.h" 31 #include "core/fetch/ResourceClientWalker.h"
32 #include "core/fetch/ResourceFetcher.h" 32 #include "core/fetch/ResourceFetcher.h"
33 #include "platform/MIMETypeRegistry.h" 33 #include "platform/MIMETypeRegistry.h"
34 #include "platform/SharedBuffer.h" 34 #include "platform/SharedBuffer.h"
35 #include "platform/network/HTTPParsers.h" 35 #include "platform/network/HTTPParsers.h"
36 #include "public/platform/WebProcessMemoryDump.h"
36 37
37 namespace blink { 38 namespace blink {
38 39
39 ResourcePtr<ScriptResource> ScriptResource::fetch(FetchRequest& request, Resourc eFetcher* fetcher) 40 ResourcePtr<ScriptResource> ScriptResource::fetch(FetchRequest& request, Resourc eFetcher* fetcher)
40 { 41 {
41 ASSERT(request.resourceRequest().frameType() == WebURLRequest::FrameTypeNone ); 42 ASSERT(request.resourceRequest().frameType() == WebURLRequest::FrameTypeNone );
42 request.mutableResourceRequest().setRequestContext(WebURLRequest::RequestCon textScript); 43 request.mutableResourceRequest().setRequestContext(WebURLRequest::RequestCon textScript);
43 return toScriptResource(fetcher->requestResource(request, ScriptResourceFact ory())); 44 return toScriptResource(fetcher->requestResource(request, ScriptResourceFact ory()));
44 } 45 }
45 46
(...skipping 19 matching lines...) Expand all
65 } 66 }
66 67
67 void ScriptResource::appendData(const char* data, unsigned length) 68 void ScriptResource::appendData(const char* data, unsigned length)
68 { 69 {
69 Resource::appendData(data, length); 70 Resource::appendData(data, length);
70 ResourceClientWalker<ScriptResourceClient> walker(m_clients); 71 ResourceClientWalker<ScriptResourceClient> walker(m_clients);
71 while (ScriptResourceClient* client = walker.next()) 72 while (ScriptResourceClient* client = walker.next())
72 client->notifyAppendData(this); 73 client->notifyAppendData(this);
73 } 74 }
74 75
76 void ScriptResource::onMemoryDump(WebProcessMemoryDump* memoryDump) const
haraken 2015/09/28 14:54:02 Why do you specialize for ScriptResource (while yo
ssid 2015/09/28 16:24:38 Ah because the Scripts keep count of the decoded s
77 {
78 Resource::onMemoryDump(memoryDump);
79 const String name = getMemoryDumpName() + "/decoded_script";
80 auto dump = memoryDump->createMemoryAllocatorDump(name);
81 dump->AddScalar("size", "bytes", m_script.string().sizeInBytes());
82 memoryDump->AddSuballocation(dump->guid(), String(WTF::Partitions::allocator PoolNameForTracing()));
83 }
84
75 AtomicString ScriptResource::mimeType() const 85 AtomicString ScriptResource::mimeType() const
76 { 86 {
77 return extractMIMETypeFromMediaType(m_response.httpHeaderField("Content-Type ")).lower(); 87 return extractMIMETypeFromMediaType(m_response.httpHeaderField("Content-Type ")).lower();
78 } 88 }
79 89
80 const String& ScriptResource::script() 90 const String& ScriptResource::script()
81 { 91 {
82 ASSERT(!isPurgeable()); 92 ASSERT(!isPurgeable());
83 ASSERT(isLoaded()); 93 ASSERT(isLoaded());
84 94
85 if (!m_script && m_data) { 95 if (!m_script && m_data) {
86 String script = decodedText(); 96 String script = decodedText();
87 m_data.clear(); 97 m_data.clear();
88 // We lie a it here and claim that script counts as encoded data (even t hough it's really decoded data). 98 // We lie a it here and claim that script counts as encoded data (even t hough it's really decoded data).
89 // That's because the MemoryCache thinks that it can clear out decoded d ata by calling destroyDecodedData(), 99 // That's because the MemoryCache thinks that it can clear out decoded d ata by calling destroyDecodedData(),
90 // but we can't destroy script in destroyDecodedData because that's our only copy of the data! 100 // but we can't destroy script in destroyDecodedData because that's our only copy of the data!
91 setEncodedSize(script.sizeInBytes()); 101 setEncodedSize(script.sizeInBytes());
92 m_script = AtomicString(script); 102 m_script = AtomicString(script);
93 } 103 }
94 104
95 return m_script.string(); 105 return m_script.string();
96 } 106 }
97 107
98 bool ScriptResource::mimeTypeAllowedByNosniff() const 108 bool ScriptResource::mimeTypeAllowedByNosniff() const
99 { 109 {
100 return parseContentTypeOptionsHeader(m_response.httpHeaderField("X-Content-T ype-Options")) != ContentTypeOptionsNosniff || MIMETypeRegistry::isSupportedJava ScriptMIMEType(mimeType()); 110 return parseContentTypeOptionsHeader(m_response.httpHeaderField("X-Content-T ype-Options")) != ContentTypeOptionsNosniff || MIMETypeRegistry::isSupportedJava ScriptMIMEType(mimeType());
101 } 111 }
102 112
103 } // namespace blink 113 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698