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), suspended_(false) { |
25 suspended_(false) { | |
26 DCHECK(session_.get()); | 25 DCHECK(session_.get()); |
27 #if defined(OS_WIN) | 26 #if defined(OS_WIN) |
28 base::PowerMonitor* power_monitor = base::PowerMonitor::Get(); | 27 base::PowerMonitor* power_monitor = base::PowerMonitor::Get(); |
29 if (power_monitor) | 28 if (power_monitor) |
30 power_monitor->AddObserver(this); | 29 power_monitor->AddObserver(this); |
31 #endif | 30 #endif |
32 } | 31 } |
33 | 32 |
34 HttpNetworkLayer::~HttpNetworkLayer() { | 33 HttpNetworkLayer::~HttpNetworkLayer() { |
35 #if defined(OS_WIN) | 34 #if defined(OS_WIN) |
36 base::PowerMonitor* power_monitor = base::PowerMonitor::Get(); | 35 base::PowerMonitor* power_monitor = base::PowerMonitor::Get(); |
37 if (power_monitor) | 36 if (power_monitor) |
38 power_monitor->RemoveObserver(this); | 37 power_monitor->RemoveObserver(this); |
39 #endif | 38 #endif |
40 } | 39 } |
(...skipping 24 matching lines...) Expand all Loading... |
65 return ERR_NETWORK_IO_SUSPENDED; | 64 return ERR_NETWORK_IO_SUSPENDED; |
66 | 65 |
67 trans->reset(new HttpNetworkTransaction(priority, GetSession())); | 66 trans->reset(new HttpNetworkTransaction(priority, GetSession())); |
68 return OK; | 67 return OK; |
69 } | 68 } |
70 | 69 |
71 HttpCache* HttpNetworkLayer::GetCache() { | 70 HttpCache* HttpNetworkLayer::GetCache() { |
72 return NULL; | 71 return NULL; |
73 } | 72 } |
74 | 73 |
75 HttpNetworkSession* HttpNetworkLayer::GetSession() { return session_.get(); } | 74 HttpNetworkSession* HttpNetworkLayer::GetSession() { |
| 75 return session_.get(); |
| 76 } |
76 | 77 |
77 void HttpNetworkLayer::OnSuspend() { | 78 void HttpNetworkLayer::OnSuspend() { |
78 suspended_ = true; | 79 suspended_ = true; |
79 | 80 |
80 if (session_.get()) | 81 if (session_.get()) |
81 session_->CloseIdleConnections(); | 82 session_->CloseIdleConnections(); |
82 } | 83 } |
83 | 84 |
84 void HttpNetworkLayer::OnResume() { | 85 void HttpNetworkLayer::OnResume() { |
85 suspended_ = false; | 86 suspended_ = false; |
86 } | 87 } |
87 | 88 |
88 } // namespace net | 89 } // namespace net |
OLD | NEW |