| OLD | NEW | 
|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chrome/renderer/net_benchmarking_extension.h" | 5 #include "chrome/renderer/net_benchmarking_extension.h" | 
| 6 | 6 | 
| 7 #include "chrome/common/benchmarking_messages.h" | 7 #include "chrome/common/benchmarking_messages.h" | 
| 8 #include "content/public/renderer/render_thread.h" | 8 #include "content/public/renderer/render_thread.h" | 
| 9 #include "third_party/WebKit/public/web/WebCache.h" | 9 #include "third_party/WebKit/public/web/WebCache.h" | 
| 10 #include "v8/include/v8.h" | 10 #include "v8/include/v8.h" | 
| 11 | 11 | 
| 12 using blink::WebCache; | 12 using blink::WebCache; | 
| 13 | 13 | 
| 14 const char kNetBenchmarkingExtensionName[] = "v8/NetBenchmarking"; | 14 const char kNetBenchmarkingExtensionName[] = "v8/NetBenchmarking"; | 
| 15 | 15 | 
| 16 namespace extensions_v8 { | 16 namespace extensions_v8 { | 
| 17 | 17 | 
| 18 class NetBenchmarkingWrapper : public v8::Extension { | 18 class NetBenchmarkingWrapper : public v8::Extension { | 
| 19  public: | 19  public: | 
| 20   NetBenchmarkingWrapper() : | 20   NetBenchmarkingWrapper() : | 
| 21       v8::Extension(kNetBenchmarkingExtensionName, | 21       v8::Extension(kNetBenchmarkingExtensionName, | 
| 22         "if (typeof(chrome) == 'undefined') {" | 22         "if (typeof(chrome) == 'undefined') {" | 
| 23         "  chrome = {};" | 23         "  chrome = {};" | 
| 24         "};" | 24         "};" | 
| 25         "if (typeof(chrome.benchmarking) == 'undefined') {" | 25         "if (typeof(chrome.benchmarking) == 'undefined') {" | 
| 26         "  chrome.benchmarking = {};" | 26         "  chrome.benchmarking = {};" | 
| 27         "};" | 27         "};" | 
| 28         "chrome.benchmarking.clearCache = function() {" | 28         "chrome.benchmarking.clearCache = function(preserve_ssl_entries) {" | 
| 29         "  native function ClearCache();" | 29         "  native function ClearCache();" | 
| 30         "  ClearCache();" | 30         "  ClearCache(preserve_ssl_entries);" | 
| 31         "};" | 31         "};" | 
| 32         "chrome.benchmarking.clearHostResolverCache = function() {" | 32         "chrome.benchmarking.clearHostResolverCache = function() {" | 
| 33         "  native function ClearHostResolverCache();" | 33         "  native function ClearHostResolverCache();" | 
| 34         "  ClearHostResolverCache();" | 34         "  ClearHostResolverCache();" | 
| 35         "};" | 35         "};" | 
| 36         "chrome.benchmarking.clearPredictorCache = function() {" | 36         "chrome.benchmarking.clearPredictorCache = function() {" | 
| 37         "  native function ClearPredictorCache();" | 37         "  native function ClearPredictorCache();" | 
| 38         "  ClearPredictorCache();" | 38         "  ClearPredictorCache();" | 
| 39         "};" | 39         "};" | 
| 40         "chrome.benchmarking.closeConnections = function() {" | 40         "chrome.benchmarking.closeConnections = function() {" | 
| (...skipping 21 matching lines...) Expand all  Loading... | 
| 62       return v8::FunctionTemplate::New(isolate, EnableSpdy); | 62       return v8::FunctionTemplate::New(isolate, EnableSpdy); | 
| 63     } else if (name->Equals( | 63     } else if (name->Equals( | 
| 64                    v8::String::NewFromUtf8(isolate, "CloseConnections"))) { | 64                    v8::String::NewFromUtf8(isolate, "CloseConnections"))) { | 
| 65       return v8::FunctionTemplate::New(isolate, CloseConnections); | 65       return v8::FunctionTemplate::New(isolate, CloseConnections); | 
| 66     } | 66     } | 
| 67 | 67 | 
| 68     return v8::Handle<v8::FunctionTemplate>(); | 68     return v8::Handle<v8::FunctionTemplate>(); | 
| 69   } | 69   } | 
| 70 | 70 | 
| 71   static void ClearCache(const v8::FunctionCallbackInfo<v8::Value>& args) { | 71   static void ClearCache(const v8::FunctionCallbackInfo<v8::Value>& args) { | 
|  | 72     bool preserve_ssl_host_entries = false; | 
|  | 73     if (args.Length() && args[0]->IsBoolean()) | 
|  | 74       preserve_ssl_host_entries = args[0]->BooleanValue(); | 
| 72     int rv; | 75     int rv; | 
| 73     content::RenderThread::Get()->Send(new ChromeViewHostMsg_ClearCache(&rv)); | 76     content::RenderThread::Get()->Send(new ChromeViewHostMsg_ClearCache( | 
|  | 77         preserve_ssl_host_entries, &rv)); | 
| 74     WebCache::clear(); | 78     WebCache::clear(); | 
| 75   } | 79   } | 
| 76 | 80 | 
| 77   static void ClearHostResolverCache( | 81   static void ClearHostResolverCache( | 
| 78       const v8::FunctionCallbackInfo<v8::Value>& args) { | 82       const v8::FunctionCallbackInfo<v8::Value>& args) { | 
| 79     int rv; | 83     int rv; | 
| 80     content::RenderThread::Get()->Send( | 84     content::RenderThread::Get()->Send( | 
| 81         new ChromeViewHostMsg_ClearHostResolverCache(&rv)); | 85         new ChromeViewHostMsg_ClearHostResolverCache(&rv)); | 
| 82   } | 86   } | 
| 83 | 87 | 
| (...skipping 17 matching lines...) Expand all  Loading... | 
| 101     content::RenderThread::Get()->Send(new ChromeViewHostMsg_EnableSpdy( | 105     content::RenderThread::Get()->Send(new ChromeViewHostMsg_EnableSpdy( | 
| 102         args[0]->BooleanValue())); | 106         args[0]->BooleanValue())); | 
| 103   } | 107   } | 
| 104 }; | 108 }; | 
| 105 | 109 | 
| 106 v8::Extension* NetBenchmarkingExtension::Get() { | 110 v8::Extension* NetBenchmarkingExtension::Get() { | 
| 107   return new NetBenchmarkingWrapper(); | 111   return new NetBenchmarkingWrapper(); | 
| 108 } | 112 } | 
| 109 | 113 | 
| 110 }  // namespace extensions_v8 | 114 }  // namespace extensions_v8 | 
| OLD | NEW | 
|---|