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/chrome_net_benchmarking.mojom.h" |
8 #include "content/public/renderer/render_thread.h" | 8 #include "content/public/renderer/render_thread.h" |
9 #include "services/service_manager/public/cpp/interface_provider.h" | |
9 #include "third_party/WebKit/public/web/WebCache.h" | 10 #include "third_party/WebKit/public/web/WebCache.h" |
10 #include "v8/include/v8.h" | 11 #include "v8/include/v8.h" |
11 | 12 |
12 using blink::WebCache; | 13 using blink::WebCache; |
13 | 14 |
14 const char kNetBenchmarkingExtensionName[] = "v8/NetBenchmarking"; | 15 const char kNetBenchmarkingExtensionName[] = "v8/NetBenchmarking"; |
15 | 16 |
16 namespace extensions_v8 { | 17 namespace extensions_v8 { |
17 | 18 |
18 class NetBenchmarkingWrapper : public v8::Extension { | 19 class NetBenchmarkingWrapper : public v8::Extension { |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
56 return v8::FunctionTemplate::New(isolate, ClearPredictorCache); | 57 return v8::FunctionTemplate::New(isolate, ClearPredictorCache); |
57 } else if (name->Equals( | 58 } else if (name->Equals( |
58 v8::String::NewFromUtf8(isolate, "CloseConnections"))) { | 59 v8::String::NewFromUtf8(isolate, "CloseConnections"))) { |
59 return v8::FunctionTemplate::New(isolate, CloseConnections); | 60 return v8::FunctionTemplate::New(isolate, CloseConnections); |
60 } | 61 } |
61 | 62 |
62 return v8::Local<v8::FunctionTemplate>(); | 63 return v8::Local<v8::FunctionTemplate>(); |
63 } | 64 } |
64 | 65 |
65 static void ClearCache(const v8::FunctionCallbackInfo<v8::Value>& args) { | 66 static void ClearCache(const v8::FunctionCallbackInfo<v8::Value>& args) { |
66 int rv; | 67 content::RenderThread* thread = content::RenderThread::Get(); |
67 content::RenderThread::Get()->Send(new ChromeViewHostMsg_ClearCache(&rv)); | 68 chrome::mojom::ChromeNetBenchmarkingPtr chrome_net_benchmarking; |
68 WebCache::clear(); | 69 thread->GetRemoteInterfaces()->GetInterface(&chrome_net_benchmarking); |
Sam McNally
2016/12/05 06:57:10
I think I'd prefer a single shared connection inst
dvallet
2016/12/07 02:21:03
Done, not sure if correctly though, PTAL
| |
70 | |
71 chrome::mojom::ChromeNetBenchmarking::ClearCacheCallback callback; | |
72 chrome_net_benchmarking->ClearCache(callback); | |
69 } | 73 } |
70 | 74 |
71 static void ClearHostResolverCache( | 75 static void ClearHostResolverCache( |
72 const v8::FunctionCallbackInfo<v8::Value>& args) { | 76 const v8::FunctionCallbackInfo<v8::Value>& args) { |
73 content::RenderThread::Get()->Send( | 77 content::RenderThread* thread = content::RenderThread::Get(); |
74 new ChromeViewHostMsg_ClearHostResolverCache()); | 78 chrome::mojom::ChromeNetBenchmarkingPtr chrome_net_benchmarking; |
79 | |
80 thread->GetRemoteInterfaces()->GetInterface(&chrome_net_benchmarking); | |
81 chrome_net_benchmarking->ClearHostResolverCache(); | |
75 } | 82 } |
76 | 83 |
77 static void ClearPredictorCache( | 84 static void ClearPredictorCache( |
78 const v8::FunctionCallbackInfo<v8::Value>& args) { | 85 const v8::FunctionCallbackInfo<v8::Value>& args) { |
79 content::RenderThread::Get()->Send( | 86 content::RenderThread* thread = content::RenderThread::Get(); |
80 new ChromeViewHostMsg_ClearPredictorCache()); | 87 chrome::mojom::ChromeNetBenchmarkingPtr chrome_net_benchmarking; |
88 | |
89 thread->GetRemoteInterfaces()->GetInterface(&chrome_net_benchmarking); | |
90 chrome_net_benchmarking->ClearPredictorCache(); | |
81 } | 91 } |
82 | 92 |
83 static void CloseConnections( | 93 static void CloseConnections( |
84 const v8::FunctionCallbackInfo<v8::Value>& args) { | 94 const v8::FunctionCallbackInfo<v8::Value>& args) { |
85 content::RenderThread::Get()->Send( | 95 content::RenderThread* thread = content::RenderThread::Get(); |
86 new ChromeViewHostMsg_CloseCurrentConnections()); | 96 chrome::mojom::ChromeNetBenchmarkingPtr chrome_net_benchmarking; |
97 | |
98 thread->GetRemoteInterfaces()->GetInterface(&chrome_net_benchmarking); | |
99 chrome_net_benchmarking->CloseCurrentConnections(); | |
87 } | 100 } |
88 }; | 101 }; |
89 | 102 |
90 v8::Extension* NetBenchmarkingExtension::Get() { | 103 v8::Extension* NetBenchmarkingExtension::Get() { |
91 return new NetBenchmarkingWrapper(); | 104 return new NetBenchmarkingWrapper(); |
92 } | 105 } |
93 | 106 |
94 } // namespace extensions_v8 | 107 } // namespace extensions_v8 |
OLD | NEW |