Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Side by Side Diff: chrome/renderer/net_benchmarking_extension.cc

Issue 2521823008: Migrate chrome_net_benchmarking_message_filter to mojo (Closed)
Patch Set: Renamed mojo class to net_benchmarking Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 v8::String::NewFromUtf8(isolate, "ClearPredictorCache"))) { 56 v8::String::NewFromUtf8(isolate, "ClearPredictorCache"))) {
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
66 static chrome::mojom::NetBenchmarking& GetNetBenchmarking() {
67 CR_DEFINE_STATIC_LOCAL(chrome::mojom::NetBenchmarkingPtr, net_benchmarking,
68 (ConnectToBrowser()));
69 return *net_benchmarking;
70 }
71
72 static chrome::mojom::NetBenchmarkingPtr ConnectToBrowser() {
73 chrome::mojom::NetBenchmarkingPtr net_benchmarking;
74 content::RenderThread::Get()->GetRemoteInterfaces()->GetInterface(
75 &net_benchmarking);
76 return net_benchmarking;
77 }
78
65 static void ClearCache(const v8::FunctionCallbackInfo<v8::Value>& args) { 79 static void ClearCache(const v8::FunctionCallbackInfo<v8::Value>& args) {
66 int rv; 80 chrome::mojom::NetBenchmarking::ClearCacheCallback callback;
67 content::RenderThread::Get()->Send(new ChromeViewHostMsg_ClearCache(&rv)); 81 GetNetBenchmarking().ClearCache(callback);
68 WebCache::clear();
69 } 82 }
70 83
71 static void ClearHostResolverCache( 84 static void ClearHostResolverCache(
72 const v8::FunctionCallbackInfo<v8::Value>& args) { 85 const v8::FunctionCallbackInfo<v8::Value>& args) {
73 content::RenderThread::Get()->Send( 86 GetNetBenchmarking().ClearHostResolverCache();
74 new ChromeViewHostMsg_ClearHostResolverCache());
75 } 87 }
76 88
77 static void ClearPredictorCache( 89 static void ClearPredictorCache(
78 const v8::FunctionCallbackInfo<v8::Value>& args) { 90 const v8::FunctionCallbackInfo<v8::Value>& args) {
79 content::RenderThread::Get()->Send( 91 GetNetBenchmarking().ClearPredictorCache();
80 new ChromeViewHostMsg_ClearPredictorCache());
81 } 92 }
82 93
83 static void CloseConnections( 94 static void CloseConnections(
84 const v8::FunctionCallbackInfo<v8::Value>& args) { 95 const v8::FunctionCallbackInfo<v8::Value>& args) {
85 content::RenderThread::Get()->Send( 96 chrome::mojom::NetBenchmarking::CloseCurrentConnectionsCallback callback;
86 new ChromeViewHostMsg_CloseCurrentConnections()); 97 GetNetBenchmarking().CloseCurrentConnections(callback);
87 } 98 }
88 }; 99 };
89 100
90 v8::Extension* NetBenchmarkingExtension::Get() { 101 v8::Extension* NetBenchmarkingExtension::Get() {
91 return new NetBenchmarkingWrapper(); 102 return new NetBenchmarkingWrapper();
92 } 103 }
93 104
94 } // namespace extensions_v8 105 } // namespace extensions_v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698