Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 72 ResourceClientWalker<ScriptResourceClient> walker(m_clients); | 72 ResourceClientWalker<ScriptResourceClient> walker(m_clients); |
| 73 while (ScriptResourceClient* client = walker.next()) | 73 while (ScriptResourceClient* client = walker.next()) |
| 74 client->notifyAppendData(this); | 74 client->notifyAppendData(this); |
| 75 } | 75 } |
| 76 | 76 |
| 77 void ScriptResource::onMemoryDump(WebMemoryDumpLevelOfDetail levelOfDetail, WebP rocessMemoryDump* memoryDump) const | 77 void ScriptResource::onMemoryDump(WebMemoryDumpLevelOfDetail levelOfDetail, WebP rocessMemoryDump* memoryDump) const |
| 78 { | 78 { |
| 79 Resource::onMemoryDump(levelOfDetail, memoryDump); | 79 Resource::onMemoryDump(levelOfDetail, memoryDump); |
| 80 const String name = getMemoryDumpName() + "/decoded_script"; | 80 const String name = getMemoryDumpName() + "/decoded_script"; |
| 81 auto dump = memoryDump->createMemoryAllocatorDump(name); | 81 auto dump = memoryDump->createMemoryAllocatorDump(name); |
| 82 dump->addScalar("size", "bytes", m_script.string().sizeInBytes()); | 82 dump->addScalar("size", "bytes", m_script.contentSizeInBytes()); |
|
hajimehoshi
2015/11/26 10:56:20
I found this changes the meaning.
| |
| 83 memoryDump->addSuballocation(dump->guid(), String(WTF::Partitions::kAllocate dObjectPoolName)); | 83 memoryDump->addSuballocation(dump->guid(), String(WTF::Partitions::kAllocate dObjectPoolName)); |
| 84 } | 84 } |
| 85 | 85 |
| 86 AtomicString ScriptResource::mimeType() const | 86 AtomicString ScriptResource::mimeType() const |
| 87 { | 87 { |
| 88 return extractMIMETypeFromMediaType(m_response.httpHeaderField("Content-Type ")).lower(); | 88 return extractMIMETypeFromMediaType(m_response.httpHeaderField("Content-Type ")).lower(); |
| 89 } | 89 } |
| 90 | 90 |
| 91 const String& ScriptResource::script() | 91 const CompressibleString& ScriptResource::script() |
| 92 { | 92 { |
| 93 ASSERT(!isPurgeable()); | 93 ASSERT(!isPurgeable()); |
| 94 ASSERT(isLoaded()); | 94 ASSERT(isLoaded()); |
| 95 | 95 |
| 96 if (!m_script && m_data) { | 96 if (m_script.isNull() && m_data) { |
|
haraken
2015/11/26 11:50:03
Shouldn't this be !m_script.isNull()?
hajimehoshi
2015/11/27 11:03:58
Old |!m_script| means |m_script| is null. I think
| |
| 97 String script = decodedText(); | 97 String script = decodedText(); |
| 98 m_data.clear(); | 98 m_data.clear(); |
| 99 // We lie a it here and claim that script counts as encoded data (even t hough it's really decoded data). | 99 // We lie a it here and claim that script counts as encoded data (even t hough it's really decoded data). |
| 100 // That's because the MemoryCache thinks that it can clear out decoded d ata by calling destroyDecodedData(), | 100 // That's because the MemoryCache thinks that it can clear out decoded d ata by calling destroyDecodedData(), |
| 101 // but we can't destroy script in destroyDecodedData because that's our only copy of the data! | 101 // but we can't destroy script in destroyDecodedData because that's our only copy of the data! |
| 102 setEncodedSize(script.sizeInBytes()); | 102 setEncodedSize(script.sizeInBytes()); |
| 103 m_script = AtomicString(script); | 103 m_script = CompressibleString(script.impl()); |
| 104 } | 104 } |
| 105 | 105 |
| 106 return m_script.string(); | 106 return m_script; |
| 107 } | 107 } |
| 108 | 108 |
| 109 void ScriptResource::destroyDecodedDataForFailedRevalidation() | 109 void ScriptResource::destroyDecodedDataForFailedRevalidation() |
| 110 { | 110 { |
| 111 m_script = AtomicString(); | 111 m_script = CompressibleString(StringImpl::empty()); |
| 112 } | 112 } |
| 113 | 113 |
| 114 bool ScriptResource::mimeTypeAllowedByNosniff() const | 114 bool ScriptResource::mimeTypeAllowedByNosniff() const |
| 115 { | 115 { |
| 116 return parseContentTypeOptionsHeader(m_response.httpHeaderField("X-Content-T ype-Options")) != ContentTypeOptionsNosniff || MIMETypeRegistry::isSupportedJava ScriptMIMEType(mimeType()); | 116 return parseContentTypeOptionsHeader(m_response.httpHeaderField("X-Content-T ype-Options")) != ContentTypeOptionsNosniff || MIMETypeRegistry::isSupportedJava ScriptMIMEType(mimeType()); |
| 117 } | 117 } |
| 118 | 118 |
| 119 bool ScriptResource::mustRefetchDueToIntegrityMetadata(const FetchRequest& reque st) const | 119 bool ScriptResource::mustRefetchDueToIntegrityMetadata(const FetchRequest& reque st) const |
| 120 { | 120 { |
| 121 if (request.integrityMetadata().isEmpty()) | 121 if (request.integrityMetadata().isEmpty()) |
| 122 return false; | 122 return false; |
| 123 | 123 |
| 124 return !IntegrityMetadata::setsEqual(m_integrityMetadata, request.integrityM etadata()); | 124 return !IntegrityMetadata::setsEqual(m_integrityMetadata, request.integrityM etadata()); |
| 125 } | 125 } |
| 126 | 126 |
| 127 } // namespace blink | 127 } // namespace blink |
| OLD | NEW |