| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/renderer/renderer_webkitplatformsupport_impl.h" | 5 #include "content/renderer/renderer_webkitplatformsupport_impl.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 322 blink::WebMessagePortChannel** channel2) { | 322 blink::WebMessagePortChannel** channel2) { |
| 323 WebMessagePortChannelImpl::CreatePair( | 323 WebMessagePortChannelImpl::CreatePair( |
| 324 child_thread_loop_.get(), channel1, channel2); | 324 child_thread_loop_.get(), channel1, channel2); |
| 325 } | 325 } |
| 326 | 326 |
| 327 blink::WebPrescientNetworking* | 327 blink::WebPrescientNetworking* |
| 328 RendererWebKitPlatformSupportImpl::prescientNetworking() { | 328 RendererWebKitPlatformSupportImpl::prescientNetworking() { |
| 329 return GetContentClient()->renderer()->GetPrescientNetworking(); | 329 return GetContentClient()->renderer()->GetPrescientNetworking(); |
| 330 } | 330 } |
| 331 | 331 |
| 332 bool | |
| 333 RendererWebKitPlatformSupportImpl::CheckPreparsedJsCachingEnabled() const { | |
| 334 static bool checked = false; | |
| 335 static bool result = false; | |
| 336 if (!checked) { | |
| 337 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | |
| 338 result = command_line.HasSwitch(switches::kEnablePreparsedJsCaching); | |
| 339 checked = true; | |
| 340 } | |
| 341 return result; | |
| 342 } | |
| 343 | |
| 344 void RendererWebKitPlatformSupportImpl::cacheMetadata( | 332 void RendererWebKitPlatformSupportImpl::cacheMetadata( |
| 345 const blink::WebURL& url, | 333 const blink::WebURL& url, |
| 346 double response_time, | 334 double response_time, |
| 347 const char* data, | 335 const char* data, |
| 348 size_t size) { | 336 size_t size) { |
| 349 if (!CheckPreparsedJsCachingEnabled()) | |
| 350 return; | |
| 351 | |
| 352 // Let the browser know we generated cacheable metadata for this resource. The | 337 // Let the browser know we generated cacheable metadata for this resource. The |
| 353 // browser may cache it and return it on subsequent responses to speed | 338 // browser may cache it and return it on subsequent responses to speed |
| 354 // the processing of this resource. | 339 // the processing of this resource. |
| 355 std::vector<char> copy(data, data + size); | 340 std::vector<char> copy(data, data + size); |
| 356 RenderThread::Get()->Send( | 341 RenderThread::Get()->Send( |
| 357 new ViewHostMsg_DidGenerateCacheableMetadata(url, response_time, copy)); | 342 new ViewHostMsg_DidGenerateCacheableMetadata(url, response_time, copy)); |
| 358 } | 343 } |
| 359 | 344 |
| 360 WebString RendererWebKitPlatformSupportImpl::defaultLocale() { | 345 WebString RendererWebKitPlatformSupportImpl::defaultLocale() { |
| 361 return base::ASCIIToUTF16(RenderThread::Get()->GetLocale()); | 346 return base::ASCIIToUTF16(RenderThread::Get()->GetLocale()); |
| (...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1187 void RendererWebKitPlatformSupportImpl::MockBatteryStatusChangedForTesting( | 1172 void RendererWebKitPlatformSupportImpl::MockBatteryStatusChangedForTesting( |
| 1188 const blink::WebBatteryStatus& status) { | 1173 const blink::WebBatteryStatus& status) { |
| 1189 PlatformEventObserverBase* observer = | 1174 PlatformEventObserverBase* observer = |
| 1190 platform_event_observers_.Lookup(blink::WebPlatformEventBattery); | 1175 platform_event_observers_.Lookup(blink::WebPlatformEventBattery); |
| 1191 if (!observer) | 1176 if (!observer) |
| 1192 return; | 1177 return; |
| 1193 observer->SendFakeDataForTesting((void*)&status); | 1178 observer->SendFakeDataForTesting((void*)&status); |
| 1194 } | 1179 } |
| 1195 | 1180 |
| 1196 } // namespace content | 1181 } // namespace content |
| OLD | NEW |