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

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

Issue 2327643003: Replace ASSERT*() with DCHECK*() in core/fetch/ and core/loader/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 3 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 21 matching lines...) Expand all
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/web_memory_allocator_dump.h" 35 #include "platform/web_memory_allocator_dump.h"
36 #include "platform/web_process_memory_dump.h" 36 #include "platform/web_process_memory_dump.h"
37 37
38 namespace blink { 38 namespace blink {
39 39
40 ScriptResource* ScriptResource::fetch(FetchRequest& request, ResourceFetcher* fe tcher) 40 ScriptResource* ScriptResource::fetch(FetchRequest& request, ResourceFetcher* fe tcher)
41 { 41 {
42 ASSERT(request.resourceRequest().frameType() == WebURLRequest::FrameTypeNone ); 42 DCHECK_EQ(request.resourceRequest().frameType(), WebURLRequest::FrameTypeNon e);
43 request.mutableResourceRequest().setRequestContext(WebURLRequest::RequestCon textScript); 43 request.mutableResourceRequest().setRequestContext(WebURLRequest::RequestCon textScript);
44 ScriptResource* resource = toScriptResource(fetcher->requestResource(request , ScriptResourceFactory())); 44 ScriptResource* resource = toScriptResource(fetcher->requestResource(request , ScriptResourceFactory()));
45 if (resource && !request.integrityMetadata().isEmpty()) 45 if (resource && !request.integrityMetadata().isEmpty())
46 resource->setIntegrityMetadata(request.integrityMetadata()); 46 resource->setIntegrityMetadata(request.integrityMetadata());
47 return resource; 47 return resource;
48 } 48 }
49 49
50 ScriptResource::ScriptResource(const ResourceRequest& resourceRequest, const Res ourceLoaderOptions& options, const String& charset) 50 ScriptResource::ScriptResource(const ResourceRequest& resourceRequest, const Res ourceLoaderOptions& options, const String& charset)
51 : TextResource(resourceRequest, Script, options, "application/javascript", c harset) 51 : TextResource(resourceRequest, Script, options, "application/javascript", c harset)
52 , m_integrityDisposition(ScriptIntegrityDisposition::NotChecked) 52 , m_integrityDisposition(ScriptIntegrityDisposition::NotChecked)
53 { 53 {
54 } 54 }
55 55
56 ScriptResource::~ScriptResource() 56 ScriptResource::~ScriptResource()
57 { 57 {
58 } 58 }
59 59
60 void ScriptResource::didAddClient(ResourceClient* client) 60 void ScriptResource::didAddClient(ResourceClient* client)
61 { 61 {
62 ASSERT(ScriptResourceClient::isExpectedType(client)); 62 DCHECK(ScriptResourceClient::isExpectedType(client));
63 Resource::didAddClient(client); 63 Resource::didAddClient(client);
64 } 64 }
65 65
66 void ScriptResource::appendData(const char* data, size_t length) 66 void ScriptResource::appendData(const char* data, size_t length)
67 { 67 {
68 Resource::appendData(data, length); 68 Resource::appendData(data, length);
69 ResourceClientWalker<ScriptResourceClient> walker(clients()); 69 ResourceClientWalker<ScriptResourceClient> walker(clients());
70 while (ScriptResourceClient* client = walker.next()) 70 while (ScriptResourceClient* client = walker.next())
71 client->notifyAppendData(this); 71 client->notifyAppendData(this);
72 } 72 }
73 73
74 void ScriptResource::onMemoryDump(WebMemoryDumpLevelOfDetail levelOfDetail, WebP rocessMemoryDump* memoryDump) const 74 void ScriptResource::onMemoryDump(WebMemoryDumpLevelOfDetail levelOfDetail, WebP rocessMemoryDump* memoryDump) const
75 { 75 {
76 Resource::onMemoryDump(levelOfDetail, memoryDump); 76 Resource::onMemoryDump(levelOfDetail, memoryDump);
77 const String name = getMemoryDumpName() + "/decoded_script"; 77 const String name = getMemoryDumpName() + "/decoded_script";
78 auto dump = memoryDump->createMemoryAllocatorDump(name); 78 auto dump = memoryDump->createMemoryAllocatorDump(name);
79 dump->addScalar("size", "bytes", m_script.charactersSizeInBytes()); 79 dump->addScalar("size", "bytes", m_script.charactersSizeInBytes());
80 memoryDump->addSuballocation(dump->guid(), String(WTF::Partitions::kAllocate dObjectPoolName)); 80 memoryDump->addSuballocation(dump->guid(), String(WTF::Partitions::kAllocate dObjectPoolName));
81 } 81 }
82 82
83 const String& ScriptResource::script() 83 const String& ScriptResource::script()
84 { 84 {
85 ASSERT(isLoaded()); 85 DCHECK(isLoaded());
86 86
87 if (m_script.isNull() && data()) { 87 if (m_script.isNull() && data()) {
88 String script = decodedText(); 88 String script = decodedText();
89 clearData(); 89 clearData();
90 // We lie a it here and claim that script counts as encoded data (even t hough it's really decoded data). 90 // We lie a it here and claim that script counts as encoded data (even t hough it's really decoded data).
91 // That's because the MemoryCache thinks that it can clear out decoded d ata by calling destroyDecodedData(), 91 // That's because the MemoryCache thinks that it can clear out decoded d ata by calling destroyDecodedData(),
92 // but we can't destroy script in destroyDecodedData because that's our only copy of the data! 92 // but we can't destroy script in destroyDecodedData because that's our only copy of the data!
93 setEncodedSize(script.charactersSizeInBytes()); 93 setEncodedSize(script.charactersSizeInBytes());
94 m_script = AtomicString(script); 94 m_script = AtomicString(script);
95 } 95 }
96 96
97 return m_script; 97 return m_script;
98 } 98 }
99 99
100 void ScriptResource::destroyDecodedDataForFailedRevalidation() 100 void ScriptResource::destroyDecodedDataForFailedRevalidation()
101 { 101 {
102 m_script = AtomicString(); 102 m_script = AtomicString();
103 } 103 }
104 104
105 bool ScriptResource::mimeTypeAllowedByNosniff() const 105 bool ScriptResource::mimeTypeAllowedByNosniff() const
106 { 106 {
107 return parseContentTypeOptionsHeader(response().httpHeaderField(HTTPNames::X _Content_Type_Options)) != ContentTypeOptionsNosniff || MIMETypeRegistry::isSupp ortedJavaScriptMIMEType(httpContentType()); 107 return parseContentTypeOptionsHeader(response().httpHeaderField(HTTPNames::X _Content_Type_Options)) != ContentTypeOptionsNosniff || MIMETypeRegistry::isSupp ortedJavaScriptMIMEType(httpContentType());
108 } 108 }
109 109
110 void ScriptResource::setIntegrityDisposition(ScriptIntegrityDisposition disposit ion) 110 void ScriptResource::setIntegrityDisposition(ScriptIntegrityDisposition disposit ion)
111 { 111 {
112 ASSERT(disposition != ScriptIntegrityDisposition::NotChecked); 112 DCHECK_NE(disposition, ScriptIntegrityDisposition::NotChecked);
113 m_integrityDisposition = disposition; 113 m_integrityDisposition = disposition;
114 } 114 }
115 bool ScriptResource::mustRefetchDueToIntegrityMetadata(const FetchRequest& reque st) const 115 bool ScriptResource::mustRefetchDueToIntegrityMetadata(const FetchRequest& reque st) const
116 { 116 {
117 if (request.integrityMetadata().isEmpty()) 117 if (request.integrityMetadata().isEmpty())
118 return false; 118 return false;
119 119
120 return !IntegrityMetadata::setsEqual(m_integrityMetadata, request.integrityM etadata()); 120 return !IntegrityMetadata::setsEqual(m_integrityMetadata, request.integrityM etadata());
121 } 121 }
122 122
123 } // namespace blink 123 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698