| 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/net_benchmarking.mojom.h" | 7 #include "chrome/common/net_benchmarking.mojom.h" |
| 8 #include "content/public/common/service_names.mojom.h" |
| 8 #include "content/public/renderer/render_thread.h" | 9 #include "content/public/renderer/render_thread.h" |
| 9 #include "services/service_manager/public/cpp/interface_provider.h" | 10 #include "services/service_manager/public/cpp/connector.h" |
| 10 #include "third_party/WebKit/public/platform/WebCache.h" | 11 #include "third_party/WebKit/public/platform/WebCache.h" |
| 11 #include "v8/include/v8.h" | 12 #include "v8/include/v8.h" |
| 12 | 13 |
| 13 using blink::WebCache; | 14 using blink::WebCache; |
| 14 | 15 |
| 15 const char kNetBenchmarkingExtensionName[] = "v8/NetBenchmarking"; | 16 const char kNetBenchmarkingExtensionName[] = "v8/NetBenchmarking"; |
| 16 | 17 |
| 17 namespace extensions_v8 { | 18 namespace extensions_v8 { |
| 18 | 19 |
| 19 class NetBenchmarkingWrapper : public v8::Extension { | 20 class NetBenchmarkingWrapper : public v8::Extension { |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 } | 65 } |
| 65 | 66 |
| 66 static chrome::mojom::NetBenchmarking& GetNetBenchmarking() { | 67 static chrome::mojom::NetBenchmarking& GetNetBenchmarking() { |
| 67 CR_DEFINE_STATIC_LOCAL(chrome::mojom::NetBenchmarkingPtr, net_benchmarking, | 68 CR_DEFINE_STATIC_LOCAL(chrome::mojom::NetBenchmarkingPtr, net_benchmarking, |
| 68 (ConnectToBrowser())); | 69 (ConnectToBrowser())); |
| 69 return *net_benchmarking; | 70 return *net_benchmarking; |
| 70 } | 71 } |
| 71 | 72 |
| 72 static chrome::mojom::NetBenchmarkingPtr ConnectToBrowser() { | 73 static chrome::mojom::NetBenchmarkingPtr ConnectToBrowser() { |
| 73 chrome::mojom::NetBenchmarkingPtr net_benchmarking; | 74 chrome::mojom::NetBenchmarkingPtr net_benchmarking; |
| 74 content::RenderThread::Get()->GetRemoteInterfaces()->GetInterface( | 75 content::RenderThread::Get()->GetConnector()->BindInterface( |
| 75 &net_benchmarking); | 76 content::mojom::kBrowserServiceName, &net_benchmarking); |
| 76 return net_benchmarking; | 77 return net_benchmarking; |
| 77 } | 78 } |
| 78 | 79 |
| 79 static void ClearCache(const v8::FunctionCallbackInfo<v8::Value>& args) { | 80 static void ClearCache(const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 80 int rv; | 81 int rv; |
| 81 GetNetBenchmarking().ClearCache(&rv); | 82 GetNetBenchmarking().ClearCache(&rv); |
| 82 WebCache::clear(); | 83 WebCache::clear(); |
| 83 } | 84 } |
| 84 | 85 |
| 85 static void ClearHostResolverCache( | 86 static void ClearHostResolverCache( |
| (...skipping 10 matching lines...) Expand all Loading... |
| 96 const v8::FunctionCallbackInfo<v8::Value>& args) { | 97 const v8::FunctionCallbackInfo<v8::Value>& args) { |
| 97 GetNetBenchmarking().CloseCurrentConnections(); | 98 GetNetBenchmarking().CloseCurrentConnections(); |
| 98 } | 99 } |
| 99 }; | 100 }; |
| 100 | 101 |
| 101 v8::Extension* NetBenchmarkingExtension::Get() { | 102 v8::Extension* NetBenchmarkingExtension::Get() { |
| 102 return new NetBenchmarkingWrapper(); | 103 return new NetBenchmarkingWrapper(); |
| 103 } | 104 } |
| 104 | 105 |
| 105 } // namespace extensions_v8 | 106 } // namespace extensions_v8 |
| OLD | NEW |