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 "net/http/http_network_layer.h" | 5 #include "net/http/http_network_layer.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/power_monitor/power_monitor.h" | 8 #include "base/power_monitor/power_monitor.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "net/http/http_network_session.h" | 12 #include "net/http/http_network_session.h" |
13 #include "net/http/http_network_transaction.h" | 13 #include "net/http/http_network_transaction.h" |
14 #include "net/http/http_server_properties_impl.h" | 14 #include "net/http/http_server_properties_impl.h" |
15 #include "net/http/http_stream_factory_impl_job.h" | 15 #include "net/http/http_stream_factory_impl_job.h" |
16 #include "net/spdy/spdy_framer.h" | 16 #include "net/spdy/spdy_framer.h" |
17 #include "net/spdy/spdy_session.h" | 17 #include "net/spdy/spdy_session.h" |
18 #include "net/spdy/spdy_session_pool.h" | 18 #include "net/spdy/spdy_session_pool.h" |
19 | 19 |
20 namespace net { | 20 namespace net { |
21 | 21 |
22 //----------------------------------------------------------------------------- | 22 //----------------------------------------------------------------------------- |
23 HttpNetworkLayer::HttpNetworkLayer(HttpNetworkSession* session) | 23 HttpNetworkLayer::HttpNetworkLayer(HttpNetworkSession* session) |
24 : session_(session), | 24 : session_(session), |
25 suspended_(false) { | 25 suspended_(false) { |
26 DCHECK(session_.get()); | 26 DCHECK(session_.get()); |
27 #if defined(OS_WIN) | 27 #if defined(OS_WIN) |
28 base::PowerMonitor::AddObserver(this); | 28 base::PowerMonitor* power_monitor = base::PowerMonitor::Get(); |
| 29 if (power_monitor) |
| 30 power_monitor->AddObserver(this); |
29 #endif | 31 #endif |
30 } | 32 } |
31 | 33 |
32 HttpNetworkLayer::~HttpNetworkLayer() { | 34 HttpNetworkLayer::~HttpNetworkLayer() { |
33 #if defined(OS_WIN) | 35 #if defined(OS_WIN) |
34 base::PowerMonitor::RemoveObserver(this); | 36 base::PowerMonitor* power_monitor = base::PowerMonitor::Get(); |
| 37 if (power_monitor) |
| 38 power_monitor->RemoveObserver(this); |
35 #endif | 39 #endif |
36 } | 40 } |
37 | 41 |
38 //----------------------------------------------------------------------------- | 42 //----------------------------------------------------------------------------- |
39 | 43 |
40 // static | 44 // static |
41 HttpTransactionFactory* HttpNetworkLayer::CreateFactory( | 45 HttpTransactionFactory* HttpNetworkLayer::CreateFactory( |
42 HttpNetworkSession* session) { | 46 HttpNetworkSession* session) { |
43 DCHECK(session); | 47 DCHECK(session); |
44 | 48 |
(...skipping 30 matching lines...) Expand all Loading... |
75 | 79 |
76 if (session_.get()) | 80 if (session_.get()) |
77 session_->CloseIdleConnections(); | 81 session_->CloseIdleConnections(); |
78 } | 82 } |
79 | 83 |
80 void HttpNetworkLayer::OnResume() { | 84 void HttpNetworkLayer::OnResume() { |
81 suspended_ = false; | 85 suspended_ = false; |
82 } | 86 } |
83 | 87 |
84 } // namespace net | 88 } // namespace net |
OLD | NEW |