| 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 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 blink::WebMessagePortChannel** channel2) { | 325 blink::WebMessagePortChannel** channel2) { |
| 326 WebMessagePortChannelImpl::CreatePair( | 326 WebMessagePortChannelImpl::CreatePair( |
| 327 child_thread_loop_.get(), channel1, channel2); | 327 child_thread_loop_.get(), channel1, channel2); |
| 328 } | 328 } |
| 329 | 329 |
| 330 blink::WebPrescientNetworking* | 330 blink::WebPrescientNetworking* |
| 331 RendererWebKitPlatformSupportImpl::prescientNetworking() { | 331 RendererWebKitPlatformSupportImpl::prescientNetworking() { |
| 332 return GetContentClient()->renderer()->GetPrescientNetworking(); | 332 return GetContentClient()->renderer()->GetPrescientNetworking(); |
| 333 } | 333 } |
| 334 | 334 |
| 335 bool | |
| 336 RendererWebKitPlatformSupportImpl::CheckPreparsedJsCachingEnabled() const { | |
| 337 static bool checked = false; | |
| 338 static bool result = false; | |
| 339 if (!checked) { | |
| 340 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | |
| 341 result = command_line.HasSwitch(switches::kEnablePreparsedJsCaching); | |
| 342 checked = true; | |
| 343 } | |
| 344 return result; | |
| 345 } | |
| 346 | |
| 347 void RendererWebKitPlatformSupportImpl::cacheMetadata( | 335 void RendererWebKitPlatformSupportImpl::cacheMetadata( |
| 348 const blink::WebURL& url, | 336 const blink::WebURL& url, |
| 349 double response_time, | 337 double response_time, |
| 350 const char* data, | 338 const char* data, |
| 351 size_t size) { | 339 size_t size) { |
| 352 if (!CheckPreparsedJsCachingEnabled()) | |
| 353 return; | |
| 354 | |
| 355 // Let the browser know we generated cacheable metadata for this resource. The | 340 // Let the browser know we generated cacheable metadata for this resource. The |
| 356 // browser may cache it and return it on subsequent responses to speed | 341 // browser may cache it and return it on subsequent responses to speed |
| 357 // the processing of this resource. | 342 // the processing of this resource. |
| 358 std::vector<char> copy(data, data + size); | 343 std::vector<char> copy(data, data + size); |
| 359 RenderThread::Get()->Send( | 344 RenderThread::Get()->Send( |
| 360 new ViewHostMsg_DidGenerateCacheableMetadata(url, response_time, copy)); | 345 new ViewHostMsg_DidGenerateCacheableMetadata(url, response_time, copy)); |
| 361 } | 346 } |
| 362 | 347 |
| 363 WebString RendererWebKitPlatformSupportImpl::defaultLocale() { | 348 WebString RendererWebKitPlatformSupportImpl::defaultLocale() { |
| 364 return base::ASCIIToUTF16(RenderThread::Get()->GetLocale()); | 349 return base::ASCIIToUTF16(RenderThread::Get()->GetLocale()); |
| (...skipping 780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1145 battery_status_dispatcher_->SetListener(listener); | 1130 battery_status_dispatcher_->SetListener(listener); |
| 1146 } | 1131 } |
| 1147 | 1132 |
| 1148 // static | 1133 // static |
| 1149 void RendererWebKitPlatformSupportImpl::MockBatteryStatusChangedForTesting( | 1134 void RendererWebKitPlatformSupportImpl::MockBatteryStatusChangedForTesting( |
| 1150 const blink::WebBatteryStatus& status) { | 1135 const blink::WebBatteryStatus& status) { |
| 1151 g_test_battery_status_dispatcher.Get().PostBatteryStatusChange(status); | 1136 g_test_battery_status_dispatcher.Get().PostBatteryStatusChange(status); |
| 1152 } | 1137 } |
| 1153 | 1138 |
| 1154 } // namespace content | 1139 } // namespace content |
| OLD | NEW |