Index: components/cronet/android/cronet_url_request_context_adapter.cc |
diff --git a/components/cronet/android/url_request_context_adapter.cc b/components/cronet/android/cronet_url_request_context_adapter.cc |
similarity index 82% |
copy from components/cronet/android/url_request_context_adapter.cc |
copy to components/cronet/android/cronet_url_request_context_adapter.cc |
index 7c99244781d467e9d641e830c58adc62c440ea5c..1127161108b63960b414dd7bd98d99ecb8ecb6f8 100644 |
--- a/components/cronet/android/url_request_context_adapter.cc |
+++ b/components/cronet/android/cronet_url_request_context_adapter.cc |
@@ -2,7 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "components/cronet/android/url_request_context_adapter.h" |
+#include "components/cronet/android/cronet_url_request_context_adapter.h" |
#include "base/bind.h" |
#include "base/files/file_util.h" |
@@ -112,14 +112,12 @@ class BasicNetworkDelegate : public net::NetworkDelegate { |
namespace cronet { |
-URLRequestContextAdapter::URLRequestContextAdapter( |
- URLRequestContextAdapterDelegate* delegate, |
- std::string user_agent) { |
+CronetURLRequestContextAdapter::CronetURLRequestContextAdapter( |
+ CronetURLRequestContextAdapterDelegate* delegate) { |
delegate_ = delegate; |
- user_agent_ = user_agent; |
} |
-void URLRequestContextAdapter::Initialize( |
+void CronetURLRequestContextAdapter::Initialize( |
scoped_ptr<URLRequestContextConfig> config) { |
network_thread_ = new base::Thread("network"); |
base::Thread::Options options; |
@@ -128,12 +126,12 @@ void URLRequestContextAdapter::Initialize( |
GetNetworkTaskRunner()->PostTask( |
FROM_HERE, |
- base::Bind(&URLRequestContextAdapter::InitializeURLRequestContext, |
+ base::Bind(&CronetURLRequestContextAdapter::InitializeURLRequestContext, |
this, |
Passed(&config))); |
} |
-void URLRequestContextAdapter::InitializeURLRequestContext( |
+void CronetURLRequestContextAdapter::InitializeURLRequestContext( |
scoped_ptr<URLRequestContextConfig> config) { |
// TODO(mmenke): Add method to have the builder enable SPDY. |
net::URLRequestContextBuilder context_builder; |
@@ -158,8 +156,7 @@ void URLRequestContextAdapter::InitializeURLRequestContext( |
if (quic_hint.port <= std::numeric_limits<uint16>::min() || |
quic_hint.port > std::numeric_limits<uint16>::max()) { |
- LOG(ERROR) << "Invalid QUIC hint port: " |
- << quic_hint.port; |
+ LOG(ERROR) << "Invalid QUIC hint port: " << quic_hint.port; |
continue; |
} |
@@ -179,31 +176,22 @@ void URLRequestContextAdapter::InitializeURLRequestContext( |
1.0f); |
} |
} |
- |
- if (VLOG_IS_ON(2)) { |
- net_log_observer_.reset(new NetLogObserver()); |
- context_->net_log()->AddThreadSafeObserver(net_log_observer_.get(), |
- net::NetLog::LOG_ALL_BUT_BYTES); |
- } |
+ user_agent_ = config->user_agent; |
delegate_->OnContextInitialized(this); |
} |
-URLRequestContextAdapter::~URLRequestContextAdapter() { |
- if (net_log_observer_) { |
- context_->net_log()->RemoveThreadSafeObserver(net_log_observer_.get()); |
- net_log_observer_.reset(); |
- } |
+CronetURLRequestContextAdapter::~CronetURLRequestContextAdapter() { |
StopNetLog(); |
// TODO(mef): Ensure that |network_thread_| is destroyed properly. |
} |
-const std::string& URLRequestContextAdapter::GetUserAgent( |
+const std::string& CronetURLRequestContextAdapter::GetUserAgent( |
const GURL& url) const { |
return user_agent_; |
} |
-net::URLRequestContext* URLRequestContextAdapter::GetURLRequestContext() { |
+net::URLRequestContext* CronetURLRequestContextAdapter::GetURLRequestContext() { |
if (!context_) { |
LOG(ERROR) << "URLRequestContext is not set up"; |
} |
@@ -211,11 +199,12 @@ net::URLRequestContext* URLRequestContextAdapter::GetURLRequestContext() { |
} |
scoped_refptr<base::SingleThreadTaskRunner> |
-URLRequestContextAdapter::GetNetworkTaskRunner() const { |
+CronetURLRequestContextAdapter::GetNetworkTaskRunner() const { |
return network_thread_->message_loop_proxy(); |
} |
-void URLRequestContextAdapter::StartNetLogToFile(const std::string& file_name) { |
+void CronetURLRequestContextAdapter::StartNetLogToFile( |
+ const std::string& file_name) { |
mmenke
2014/10/03 20:45:59
These should actually be run on the network thread
mef
2014/10/06 14:52:43
Done.
|
// Do nothing if already logging to a file. |
if (net_log_logger_) |
return; |
@@ -230,16 +219,10 @@ void URLRequestContextAdapter::StartNetLogToFile(const std::string& file_name) { |
net_log_logger_->StartObserving(context_->net_log()); |
} |
-void URLRequestContextAdapter::StopNetLog() { |
+void CronetURLRequestContextAdapter::StopNetLog() { |
if (net_log_logger_) { |
net_log_logger_->StopObserving(); |
net_log_logger_.reset(); |
} |
} |
- |
-void NetLogObserver::OnAddEntry(const net::NetLog::Entry& entry) { |
- VLOG(2) << "Net log entry: type=" << entry.type() |
- << ", source=" << entry.source().type << ", phase=" << entry.phase(); |
-} |
- |
} // namespace cronet |
mmenke
2014/10/03 20:45:59
nit: Blank line before end of namespace.
mef
2014/10/06 14:52:43
Done.
|