OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/chrome_net_benchmarking_message_filter.h" | 5 #include "chrome/browser/chrome_net_benchmarking_message_filter.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 net::URLRequestContextGetter* request_context) | 36 net::URLRequestContextGetter* request_context) |
37 : BrowserMessageFilter(ChromeBenchmarkingMsgStart), | 37 : BrowserMessageFilter(ChromeBenchmarkingMsgStart), |
38 profile_(profile), | 38 profile_(profile), |
39 request_context_(request_context) { | 39 request_context_(request_context) { |
40 } | 40 } |
41 | 41 |
42 ChromeNetBenchmarkingMessageFilter::~ChromeNetBenchmarkingMessageFilter() { | 42 ChromeNetBenchmarkingMessageFilter::~ChromeNetBenchmarkingMessageFilter() { |
43 } | 43 } |
44 | 44 |
45 bool ChromeNetBenchmarkingMessageFilter::OnMessageReceived( | 45 bool ChromeNetBenchmarkingMessageFilter::OnMessageReceived( |
46 const IPC::Message& message, bool* message_was_ok) { | 46 const IPC::Message& message) { |
47 bool handled = true; | 47 bool handled = true; |
48 IPC_BEGIN_MESSAGE_MAP_EX(ChromeNetBenchmarkingMessageFilter, message, | 48 IPC_BEGIN_MESSAGE_MAP(ChromeNetBenchmarkingMessageFilter, message) |
49 *message_was_ok) | |
50 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_CloseCurrentConnections, | 49 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_CloseCurrentConnections, |
51 OnCloseCurrentConnections) | 50 OnCloseCurrentConnections) |
52 IPC_MESSAGE_HANDLER_DELAY_REPLY(ChromeViewHostMsg_ClearCache, OnClearCache) | 51 IPC_MESSAGE_HANDLER_DELAY_REPLY(ChromeViewHostMsg_ClearCache, OnClearCache) |
53 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ClearHostResolverCache, | 52 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ClearHostResolverCache, |
54 OnClearHostResolverCache) | 53 OnClearHostResolverCache) |
55 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ClearPredictorCache, | 54 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_ClearPredictorCache, |
56 OnClearPredictorCache) | 55 OnClearPredictorCache) |
57 IPC_MESSAGE_UNHANDLED(handled = false) | 56 IPC_MESSAGE_UNHANDLED(handled = false) |
58 IPC_END_MESSAGE_MAP_EX() | 57 IPC_END_MESSAGE_MAP() |
59 return handled; | 58 return handled; |
60 } | 59 } |
61 | 60 |
62 void ChromeNetBenchmarkingMessageFilter::OnClearCache(IPC::Message* reply_msg) { | 61 void ChromeNetBenchmarkingMessageFilter::OnClearCache(IPC::Message* reply_msg) { |
63 // This function is disabled unless the user has enabled | 62 // This function is disabled unless the user has enabled |
64 // benchmarking extensions. | 63 // benchmarking extensions. |
65 if (!CheckBenchmarkingEnabled()) { | 64 if (!CheckBenchmarkingEnabled()) { |
66 NOTREACHED() << "Received unexpected benchmarking IPC"; | 65 NOTREACHED() << "Received unexpected benchmarking IPC"; |
67 return; | 66 return; |
68 } | 67 } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 static bool checked = false; | 140 static bool checked = false; |
142 static bool result = false; | 141 static bool result = false; |
143 if (!checked) { | 142 if (!checked) { |
144 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 143 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
145 result = command_line.HasSwitch(switches::kEnableNetBenchmarking); | 144 result = command_line.HasSwitch(switches::kEnableNetBenchmarking); |
146 checked = true; | 145 checked = true; |
147 } | 146 } |
148 return result; | 147 return result; |
149 } | 148 } |
150 | 149 |
OLD | NEW |