Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/cronet/android/url_request_context_peer.h" | 5 #include "components/cronet/android/url_request_context_peer.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "components/cronet/url_request_context_config.h" | 10 #include "components/cronet/url_request_context_config.h" |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 107 | 107 |
| 108 DISALLOW_COPY_AND_ASSIGN(BasicNetworkDelegate); | 108 DISALLOW_COPY_AND_ASSIGN(BasicNetworkDelegate); |
| 109 }; | 109 }; |
| 110 | 110 |
| 111 } // namespace | 111 } // namespace |
| 112 | 112 |
| 113 namespace cronet { | 113 namespace cronet { |
| 114 | 114 |
| 115 URLRequestContextPeer::URLRequestContextPeer( | 115 URLRequestContextPeer::URLRequestContextPeer( |
| 116 URLRequestContextPeerDelegate* delegate, | 116 URLRequestContextPeerDelegate* delegate, |
| 117 std::string user_agent, | 117 std::string user_agent) { |
| 118 int logging_level) { | |
| 119 delegate_ = delegate; | 118 delegate_ = delegate; |
| 120 user_agent_ = user_agent; | 119 user_agent_ = user_agent; |
| 121 logging_level_ = logging_level; | |
| 122 } | 120 } |
| 123 | 121 |
| 124 void URLRequestContextPeer::Initialize( | 122 void URLRequestContextPeer::Initialize( |
| 125 scoped_ptr<URLRequestContextConfig> config) { | 123 scoped_ptr<URLRequestContextConfig> config) { |
| 126 network_thread_ = new base::Thread("network"); | 124 network_thread_ = new base::Thread("network"); |
| 127 base::Thread::Options options; | 125 base::Thread::Options options; |
| 128 options.message_loop_type = base::MessageLoop::TYPE_IO; | 126 options.message_loop_type = base::MessageLoop::TYPE_IO; |
| 129 network_thread_->StartWithOptions(options); | 127 network_thread_->StartWithOptions(options); |
| 130 | 128 |
| 131 GetNetworkTaskRunner()->PostTask( | 129 GetNetworkTaskRunner()->PostTask( |
| 132 FROM_HERE, | 130 FROM_HERE, |
| 133 base::Bind(&URLRequestContextPeer::InitializeURLRequestContext, | 131 base::Bind(&URLRequestContextPeer::InitializeURLRequestContext, |
| 134 this, | 132 this, |
| 135 Passed(&config))); | 133 Passed(&config))); |
| 136 } | 134 } |
| 137 | 135 |
| 138 void URLRequestContextPeer::InitializeURLRequestContext( | 136 void URLRequestContextPeer::InitializeURLRequestContext( |
| 139 scoped_ptr<URLRequestContextConfig> config) { | 137 scoped_ptr<URLRequestContextConfig> config) { |
| 140 // TODO(mmenke): Add method to have the builder enable SPDY. | 138 // TODO(mmenke): Add method to have the builder enable SPDY. |
| 141 net::URLRequestContextBuilder context_builder; | 139 net::URLRequestContextBuilder context_builder; |
| 142 context_builder.set_network_delegate(new BasicNetworkDelegate()); | 140 context_builder.set_network_delegate(new BasicNetworkDelegate()); |
| 143 context_builder.set_proxy_config_service( | 141 context_builder.set_proxy_config_service( |
| 144 new net::ProxyConfigServiceFixed(net::ProxyConfig())); | 142 new net::ProxyConfigServiceFixed(net::ProxyConfig())); |
| 145 config->ConfigureURLRequestContextBuilder(&context_builder); | 143 config->ConfigureURLRequestContextBuilder(&context_builder); |
| 146 | 144 |
| 147 context_.reset(context_builder.Build()); | 145 context_.reset(context_builder.Build()); |
| 148 | 146 |
| 149 if (VLOG_IS_ON(2)) { | 147 if (VLOG_IS_ON(2)) { |
| 150 net_log_observer_.reset(new NetLogObserver(logging_level_)); | 148 net_log_observer_.reset(new NetLogObserver()); |
| 151 context_->net_log()->AddThreadSafeObserver(net_log_observer_.get(), | 149 context_->net_log()->AddThreadSafeObserver(net_log_observer_.get(), |
| 152 net::NetLog::LOG_ALL_BUT_BYTES); | 150 net::NetLog::LOG_ALL_BUT_BYTES); |
| 153 } | 151 } |
| 154 | 152 |
| 155 delegate_->OnContextInitialized(this); | 153 delegate_->OnContextInitialized(this); |
| 156 } | 154 } |
| 157 | 155 |
| 158 URLRequestContextPeer::~URLRequestContextPeer() { | 156 URLRequestContextPeer::~URLRequestContextPeer() { |
| 159 if (net_log_observer_) { | 157 if (net_log_observer_) { |
| 160 context_->net_log()->RemoveThreadSafeObserver(net_log_observer_.get()); | 158 context_->net_log()->RemoveThreadSafeObserver(net_log_observer_.get()); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 196 } | 194 } |
| 197 | 195 |
| 198 void URLRequestContextPeer::StopNetLog() { | 196 void URLRequestContextPeer::StopNetLog() { |
| 199 if (net_log_logger_) { | 197 if (net_log_logger_) { |
| 200 net_log_logger_->StopObserving(); | 198 net_log_logger_->StopObserving(); |
| 201 net_log_logger_.reset(); | 199 net_log_logger_.reset(); |
| 202 } | 200 } |
| 203 } | 201 } |
| 204 | 202 |
| 205 void NetLogObserver::OnAddEntry(const net::NetLog::Entry& entry) { | 203 void NetLogObserver::OnAddEntry(const net::NetLog::Entry& entry) { |
| 206 if (VLOG_IS_ON(2)) { | 204 if (VLOG_IS_ON(2)) { |
|
mmenke
2014/08/07 15:07:27
This is redundant with the VLOG(2), below
mef
2014/08/07 15:39:57
Done.
| |
| 207 VLOG(2) << "Net log entry: type=" << entry.type() | 205 VLOG(2) << "Net log entry: type=" << entry.type() |
| 208 << ", source=" << entry.source().type | 206 << ", source=" << entry.source().type |
| 209 << ", phase=" << entry.phase(); | 207 << ", phase=" << entry.phase(); |
| 210 } | 208 } |
| 211 } | 209 } |
| 212 | 210 |
| 213 } // namespace cronet | 211 } // namespace cronet |
| OLD | NEW |