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" |
(...skipping 23 matching lines...) Expand all Loading... |
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() {" |
41 " native function CloseConnections();" | 41 " native function CloseConnections();" |
42 " CloseConnections();" | 42 " CloseConnections();" |
43 "};" | 43 "};" |
44 "chrome.benchmarking.enableSpdy = function(name) {" | |
45 " native function EnableSpdy();" | |
46 " EnableSpdy(name);" | |
47 "};" | |
48 ) {} | 44 ) {} |
49 | 45 |
50 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunctionTemplate( | 46 virtual v8::Handle<v8::FunctionTemplate> GetNativeFunctionTemplate( |
51 v8::Isolate* isolate, | 47 v8::Isolate* isolate, |
52 v8::Handle<v8::String> name) OVERRIDE { | 48 v8::Handle<v8::String> name) OVERRIDE { |
53 if (name->Equals(v8::String::NewFromUtf8(isolate, "ClearCache"))) { | 49 if (name->Equals(v8::String::NewFromUtf8(isolate, "ClearCache"))) { |
54 return v8::FunctionTemplate::New(isolate, ClearCache); | 50 return v8::FunctionTemplate::New(isolate, ClearCache); |
55 } else if (name->Equals(v8::String::NewFromUtf8( | 51 } else if (name->Equals(v8::String::NewFromUtf8( |
56 isolate, "ClearHostResolverCache"))) { | 52 isolate, "ClearHostResolverCache"))) { |
57 return v8::FunctionTemplate::New(isolate, ClearHostResolverCache); | 53 return v8::FunctionTemplate::New(isolate, ClearHostResolverCache); |
58 } else if (name->Equals( | 54 } else if (name->Equals( |
59 v8::String::NewFromUtf8(isolate, "ClearPredictorCache"))) { | 55 v8::String::NewFromUtf8(isolate, "ClearPredictorCache"))) { |
60 return v8::FunctionTemplate::New(isolate, ClearPredictorCache); | 56 return v8::FunctionTemplate::New(isolate, ClearPredictorCache); |
61 } else if (name->Equals(v8::String::NewFromUtf8(isolate, "EnableSpdy"))) { | |
62 return v8::FunctionTemplate::New(isolate, EnableSpdy); | |
63 } else if (name->Equals( | 57 } else if (name->Equals( |
64 v8::String::NewFromUtf8(isolate, "CloseConnections"))) { | 58 v8::String::NewFromUtf8(isolate, "CloseConnections"))) { |
65 return v8::FunctionTemplate::New(isolate, CloseConnections); | 59 return v8::FunctionTemplate::New(isolate, CloseConnections); |
66 } | 60 } |
67 | 61 |
68 return v8::Handle<v8::FunctionTemplate>(); | 62 return v8::Handle<v8::FunctionTemplate>(); |
69 } | 63 } |
70 | 64 |
71 static void ClearCache(const v8::FunctionCallbackInfo<v8::Value>& args) { | 65 static void ClearCache(const v8::FunctionCallbackInfo<v8::Value>& args) { |
72 int rv; | 66 int rv; |
(...skipping 13 matching lines...) Expand all Loading... |
86 int rv; | 80 int rv; |
87 content::RenderThread::Get()->Send( | 81 content::RenderThread::Get()->Send( |
88 new ChromeViewHostMsg_ClearPredictorCache(&rv)); | 82 new ChromeViewHostMsg_ClearPredictorCache(&rv)); |
89 } | 83 } |
90 | 84 |
91 static void CloseConnections( | 85 static void CloseConnections( |
92 const v8::FunctionCallbackInfo<v8::Value>& args) { | 86 const v8::FunctionCallbackInfo<v8::Value>& args) { |
93 content::RenderThread::Get()->Send( | 87 content::RenderThread::Get()->Send( |
94 new ChromeViewHostMsg_CloseCurrentConnections()); | 88 new ChromeViewHostMsg_CloseCurrentConnections()); |
95 } | 89 } |
96 | |
97 static void EnableSpdy(const v8::FunctionCallbackInfo<v8::Value>& args) { | |
98 if (!args.Length() || !args[0]->IsBoolean()) | |
99 return; | |
100 | |
101 content::RenderThread::Get()->Send(new ChromeViewHostMsg_EnableSpdy( | |
102 args[0]->BooleanValue())); | |
103 } | |
104 }; | 90 }; |
105 | 91 |
106 v8::Extension* NetBenchmarkingExtension::Get() { | 92 v8::Extension* NetBenchmarkingExtension::Get() { |
107 return new NetBenchmarkingWrapper(); | 93 return new NetBenchmarkingWrapper(); |
108 } | 94 } |
109 | 95 |
110 } // namespace extensions_v8 | 96 } // namespace extensions_v8 |
OLD | NEW |