Switch global error menu icon to vectorized MD asset
[chromium-blink-merge.git] / net / http / http_network_layer.cc
blobe0b3199bb897dcc9839f240097834e73d3e37ec6
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
3 // found in the LICENSE file.
5 #include "net/http/http_network_layer.h"
7 #include "base/logging.h"
8 #include "base/power_monitor/power_monitor.h"
9 #include "base/strings/string_number_conversions.h"
10 #include "base/strings/string_split.h"
11 #include "base/strings/string_util.h"
12 #include "net/http/http_network_session.h"
13 #include "net/http/http_network_transaction.h"
14 #include "net/http/http_server_properties_impl.h"
15 #include "net/http/http_stream_factory_impl_job.h"
16 #include "net/spdy/spdy_framer.h"
17 #include "net/spdy/spdy_session.h"
18 #include "net/spdy/spdy_session_pool.h"
20 namespace net {
22 HttpNetworkLayer::HttpNetworkLayer(HttpNetworkSession* session)
23 : session_(session),
24 suspended_(false) {
25 DCHECK(session_.get());
26 #if defined(OS_WIN)
27 base::PowerMonitor* power_monitor = base::PowerMonitor::Get();
28 if (power_monitor)
29 power_monitor->AddObserver(this);
30 #endif
33 HttpNetworkLayer::~HttpNetworkLayer() {
34 #if defined(OS_WIN)
35 base::PowerMonitor* power_monitor = base::PowerMonitor::Get();
36 if (power_monitor)
37 power_monitor->RemoveObserver(this);
38 #endif
41 // static
42 HttpTransactionFactory* HttpNetworkLayer::CreateFactory(
43 HttpNetworkSession* session) {
44 DCHECK(session);
46 return new HttpNetworkLayer(session);
49 int HttpNetworkLayer::CreateTransaction(RequestPriority priority,
50 scoped_ptr<HttpTransaction>* trans) {
51 if (suspended_)
52 return ERR_NETWORK_IO_SUSPENDED;
54 trans->reset(new HttpNetworkTransaction(priority, GetSession()));
55 return OK;
58 HttpCache* HttpNetworkLayer::GetCache() {
59 return NULL;
62 HttpNetworkSession* HttpNetworkLayer::GetSession() { return session_.get(); }
64 void HttpNetworkLayer::OnSuspend() {
65 suspended_ = true;
67 if (session_.get())
68 session_->CloseIdleConnections();
71 void HttpNetworkLayer::OnResume() {
72 suspended_ = false;
75 } // namespace net