Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Unified Diff: net/url_request/url_request.cc

Issue 501163002: Make URLRequest's constructor private, and make URLRequestContext a friend class. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge? Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/url_request/url_request.cc
diff --git a/net/url_request/url_request.cc b/net/url_request/url_request.cc
index f952088eeca1863f06aa7120560ea8643b677aa9..15b9ab7d73e9aabb22f8149cc4ee9453acfa5d48 100644
--- a/net/url_request/url_request.cc
+++ b/net/url_request/url_request.cc
@@ -198,47 +198,6 @@ void URLRequest::Delegate::OnBeforeNetworkStart(URLRequest* request,
///////////////////////////////////////////////////////////////////////////////
// URLRequest
-URLRequest::URLRequest(const GURL& url,
- RequestPriority priority,
- Delegate* delegate,
- const URLRequestContext* context,
- CookieStore* cookie_store,
- NetworkDelegate* network_delegate)
- : context_(context),
- network_delegate_(network_delegate ? network_delegate
- : context->network_delegate()),
- net_log_(BoundNetLog::Make(context->net_log(),
- NetLog::SOURCE_URL_REQUEST)),
- url_chain_(1, url),
- method_("GET"),
- referrer_policy_(CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE),
- first_party_url_policy_(NEVER_CHANGE_FIRST_PARTY_URL),
- load_flags_(LOAD_NORMAL),
- delegate_(delegate),
- is_pending_(false),
- is_redirecting_(false),
- redirect_limit_(kMaxRedirects),
- priority_(priority),
- identifier_(GenerateURLRequestIdentifier()),
- calling_delegate_(false),
- use_blocked_by_as_load_param_(false),
- before_request_callback_(base::Bind(&URLRequest::BeforeRequestComplete,
- base::Unretained(this))),
- has_notified_completion_(false),
- received_response_content_length_(0),
- creation_time_(base::TimeTicks::Now()),
- notified_before_network_start_(false),
- cookie_store_(cookie_store ? cookie_store : context->cookie_store()) {
- SIMPLE_STATS_COUNTER("URLRequestCount");
-
- // Sanity check out environment.
- DCHECK(base::MessageLoop::current())
- << "The current base::MessageLoop must exist";
-
- context->url_requests()->insert(this);
- net_log_.BeginEvent(NetLog::TYPE_REQUEST_ALIVE);
-}
-
URLRequest::~URLRequest() {
Cancel();
@@ -262,17 +221,6 @@ URLRequest::~URLRequest() {
net_log_.EndEventWithNetErrorCode(NetLog::TYPE_REQUEST_ALIVE, net_error);
}
-// static
-void URLRequest::RegisterRequestInterceptor(Interceptor* interceptor) {
- URLRequestJobManager::GetInstance()->RegisterRequestInterceptor(interceptor);
-}
-
-// static
-void URLRequest::UnregisterRequestInterceptor(Interceptor* interceptor) {
- URLRequestJobManager::GetInstance()->UnregisterRequestInterceptor(
- interceptor);
-}
-
void URLRequest::EnableChunkedUpload() {
DCHECK(!upload_data_stream_ || upload_data_stream_->is_chunked());
if (!upload_data_stream_) {
@@ -634,6 +582,58 @@ void URLRequest::Start() {
///////////////////////////////////////////////////////////////////////////////
+URLRequest::URLRequest(const GURL& url,
+ RequestPriority priority,
+ Delegate* delegate,
+ const URLRequestContext* context,
+ CookieStore* cookie_store,
+ NetworkDelegate* network_delegate)
+ : context_(context),
+ network_delegate_(network_delegate ? network_delegate
+ : context->network_delegate()),
+ net_log_(BoundNetLog::Make(context->net_log(),
+ NetLog::SOURCE_URL_REQUEST)),
+ url_chain_(1, url),
+ method_("GET"),
+ referrer_policy_(CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE),
+ first_party_url_policy_(NEVER_CHANGE_FIRST_PARTY_URL),
+ load_flags_(LOAD_NORMAL),
+ delegate_(delegate),
+ is_pending_(false),
+ is_redirecting_(false),
+ redirect_limit_(kMaxRedirects),
+ priority_(priority),
+ identifier_(GenerateURLRequestIdentifier()),
+ calling_delegate_(false),
+ use_blocked_by_as_load_param_(false),
+ before_request_callback_(base::Bind(&URLRequest::BeforeRequestComplete,
+ base::Unretained(this))),
+ has_notified_completion_(false),
+ received_response_content_length_(0),
+ creation_time_(base::TimeTicks::Now()),
+ notified_before_network_start_(false),
+ cookie_store_(cookie_store ? cookie_store : context->cookie_store()) {
+ SIMPLE_STATS_COUNTER("URLRequestCount");
+
+ // Sanity check out environment.
+ DCHECK(base::MessageLoop::current())
+ << "The current base::MessageLoop must exist";
+
+ context->url_requests()->insert(this);
+ net_log_.BeginEvent(NetLog::TYPE_REQUEST_ALIVE);
+}
+
+// static
+void URLRequest::RegisterRequestInterceptor(Interceptor* interceptor) {
+ URLRequestJobManager::GetInstance()->RegisterRequestInterceptor(interceptor);
+}
+
+// static
+void URLRequest::UnregisterRequestInterceptor(Interceptor* interceptor) {
+ URLRequestJobManager::GetInstance()->UnregisterRequestInterceptor(
+ interceptor);
+}
+
void URLRequest::BeforeRequestComplete(int error) {
DCHECK(!job_.get());
DCHECK_NE(ERR_IO_PENDING, error);

Powered by Google App Engine
This is Rietveld 408576698