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

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

Issue 2521823008: Migrate chrome_net_benchmarking_message_filter to mojo (Closed)
Patch Set: Do not add NetBenchmaring interface if benchmarking is disabled 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
« no previous file with comments | « chrome/common/net_benchmarking.mojom ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 int rv;
67 content::RenderThread::Get()->Send(new ChromeViewHostMsg_ClearCache(&rv)); 81 GetNetBenchmarking().ClearCache(&rv);
68 WebCache::clear(); 82 WebCache::clear();
69 } 83 }
70 84
71 static void ClearHostResolverCache( 85 static void ClearHostResolverCache(
72 const v8::FunctionCallbackInfo<v8::Value>& args) { 86 const v8::FunctionCallbackInfo<v8::Value>& args) {
73 content::RenderThread::Get()->Send( 87 GetNetBenchmarking().ClearHostResolverCache();
74 new ChromeViewHostMsg_ClearHostResolverCache());
75 } 88 }
76 89
77 static void ClearPredictorCache( 90 static void ClearPredictorCache(
78 const v8::FunctionCallbackInfo<v8::Value>& args) { 91 const v8::FunctionCallbackInfo<v8::Value>& args) {
79 content::RenderThread::Get()->Send( 92 GetNetBenchmarking().ClearPredictorCache();
80 new ChromeViewHostMsg_ClearPredictorCache());
81 } 93 }
82 94
83 static void CloseConnections( 95 static void CloseConnections(
84 const v8::FunctionCallbackInfo<v8::Value>& args) { 96 const v8::FunctionCallbackInfo<v8::Value>& args) {
85 content::RenderThread::Get()->Send( 97 GetNetBenchmarking().CloseCurrentConnections();
86 new ChromeViewHostMsg_CloseCurrentConnections());
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
« no previous file with comments | « chrome/common/net_benchmarking.mojom ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698