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" | |
11 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
12 #include "chrome/browser/net/chrome_url_request_context.h" | 11 #include "chrome/browser/net/chrome_url_request_context.h" |
13 #include "chrome/browser/net/predictor.h" | 12 #include "chrome/browser/net/predictor.h" |
14 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/common/benchmarking_messages.h" | 14 #include "chrome/common/benchmarking_messages.h" |
16 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
17 #include "net/base/net_errors.h" | 16 #include "net/base/net_errors.h" |
18 #include "net/disk_cache/disk_cache.h" | 17 #include "net/disk_cache/disk_cache.h" |
19 #include "net/dns/host_cache.h" | 18 #include "net/dns/host_cache.h" |
20 #include "net/dns/host_resolver.h" | 19 #include "net/dns/host_resolver.h" |
21 #include "net/http/http_cache.h" | 20 #include "net/http/http_cache.h" |
22 #include "net/http/http_network_layer.h" | 21 #include "net/http/http_network_layer.h" |
23 #include "net/http/http_stream_factory.h" | 22 #include "net/http/http_stream_factory.h" |
24 | 23 |
25 namespace { | 24 namespace { |
26 | 25 |
27 void ClearCacheCallback(ChromeNetBenchmarkingMessageFilter* filter, | 26 void ClearCacheCallback(ChromeNetBenchmarkingMessageFilter* filter, |
28 IPC::Message* reply_msg, | 27 IPC::Message* reply_msg, |
29 int result) { | 28 int result) { |
30 ChromeViewHostMsg_ClearCache::WriteReplyParams(reply_msg, result); | 29 ChromeViewHostMsg_ClearCache::WriteReplyParams(reply_msg, result); |
31 filter->Send(reply_msg); | 30 filter->Send(reply_msg); |
32 } | 31 } |
33 | 32 |
34 } // namespace | 33 } // namespace |
35 | 34 |
36 ChromeNetBenchmarkingMessageFilter::ChromeNetBenchmarkingMessageFilter( | 35 ChromeNetBenchmarkingMessageFilter::ChromeNetBenchmarkingMessageFilter( |
37 Profile* profile, | 36 Profile* profile, |
38 net::URLRequestContextGetter* request_context) | 37 net::URLRequestContextGetter* request_context) |
39 : BrowserMessageFilter(ChromeBenchmarkingMsgStart), | 38 : profile_(profile), |
40 profile_(profile), | |
41 request_context_(request_context) { | 39 request_context_(request_context) { |
42 } | 40 } |
43 | 41 |
44 ChromeNetBenchmarkingMessageFilter::~ChromeNetBenchmarkingMessageFilter() { | 42 ChromeNetBenchmarkingMessageFilter::~ChromeNetBenchmarkingMessageFilter() { |
45 } | 43 } |
46 | 44 |
47 bool ChromeNetBenchmarkingMessageFilter::OnMessageReceived( | 45 bool ChromeNetBenchmarkingMessageFilter::OnMessageReceived( |
48 const IPC::Message& message, bool* message_was_ok) { | 46 const IPC::Message& message, bool* message_was_ok) { |
49 bool handled = true; | 47 bool handled = true; |
50 IPC_BEGIN_MESSAGE_MAP_EX(ChromeNetBenchmarkingMessageFilter, message, | 48 IPC_BEGIN_MESSAGE_MAP_EX(ChromeNetBenchmarkingMessageFilter, message, |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 static bool checked = false; | 159 static bool checked = false; |
162 static bool result = false; | 160 static bool result = false; |
163 if (!checked) { | 161 if (!checked) { |
164 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 162 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
165 result = command_line.HasSwitch(switches::kEnableNetBenchmarking); | 163 result = command_line.HasSwitch(switches::kEnableNetBenchmarking); |
166 checked = true; | 164 checked = true; |
167 } | 165 } |
168 return result; | 166 return result; |
169 } | 167 } |
170 | 168 |
OLD | NEW |