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

Side by Side Diff: net/url_request/url_request.cc

Issue 1502503004: Remove kuint64max. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@kint8
Patch Set: rebase Created 5 years 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 unified diff | Download patch
OLDNEW
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/url_request/url_request.h" 5 #include "net/url_request/url_request.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 namespace net { 49 namespace net {
50 50
51 namespace { 51 namespace {
52 52
53 // Max number of http redirects to follow. Same number as gecko. 53 // Max number of http redirects to follow. Same number as gecko.
54 const int kMaxRedirects = 20; 54 const int kMaxRedirects = 20;
55 55
56 // TODO(battre): Delete this, see http://crbug.com/89321: 56 // TODO(battre): Delete this, see http://crbug.com/89321:
57 // This counter keeps track of the identifiers used for URL requests so far. 57 // This counter keeps track of the identifiers used for URL requests so far.
58 // 0 is reserved to represent an invalid ID. 58 // 0 is reserved to represent an invalid ID.
59 uint64 g_next_url_request_identifier = 1; 59 uint64_t g_next_url_request_identifier = 1;
60 60
61 // This lock protects g_next_url_request_identifier. 61 // This lock protects g_next_url_request_identifier.
62 base::LazyInstance<base::Lock>::Leaky 62 base::LazyInstance<base::Lock>::Leaky
63 g_next_url_request_identifier_lock = LAZY_INSTANCE_INITIALIZER; 63 g_next_url_request_identifier_lock = LAZY_INSTANCE_INITIALIZER;
64 64
65 // Returns an prior unused identifier for URL requests. 65 // Returns an prior unused identifier for URL requests.
66 uint64 GenerateURLRequestIdentifier() { 66 uint64_t GenerateURLRequestIdentifier() {
67 base::AutoLock lock(g_next_url_request_identifier_lock.Get()); 67 base::AutoLock lock(g_next_url_request_identifier_lock.Get());
68 return g_next_url_request_identifier++; 68 return g_next_url_request_identifier++;
69 } 69 }
70 70
71 // True once the first URLRequest was started. 71 // True once the first URLRequest was started.
72 bool g_url_requests_started = false; 72 bool g_url_requests_started = false;
73 73
74 // True if cookies are accepted by default. 74 // True if cookies are accepted by default.
75 bool g_default_can_use_cookies = true; 75 bool g_default_can_use_cookies = true;
76 76
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
681 return; 681 return;
682 } 682 }
683 DoCancel(error, ssl_info); 683 DoCancel(error, ssl_info);
684 } 684 }
685 685
686 void URLRequest::DoCancel(int error, const SSLInfo& ssl_info) { 686 void URLRequest::DoCancel(int error, const SSLInfo& ssl_info) {
687 DCHECK(error < 0); 687 DCHECK(error < 0);
688 // ~500,000 ERR_ABORTED < 100ms in Canary channel a day. Sample .01% to get 688 // ~500,000 ERR_ABORTED < 100ms in Canary channel a day. Sample .01% to get
689 // ~50 reports a day. 689 // ~50 reports a day.
690 // TODO(csharrison) Remove this code when crbug.com/557430 is resolved. 690 // TODO(csharrison) Remove this code when crbug.com/557430 is resolved.
691 int64 request_time = 691 int64_t request_time =
692 (base::TimeTicks::Now() - creation_time_).InMilliseconds(); 692 (base::TimeTicks::Now() - creation_time_).InMilliseconds();
693 if (!has_notified_completion_ && error == ERR_ABORTED && 693 if (!has_notified_completion_ && error == ERR_ABORTED &&
694 request_time <= 100 && load_flags_ & LOAD_MAIN_FRAME && 694 request_time <= 100 && load_flags_ & LOAD_MAIN_FRAME &&
695 base::RandDouble() < .00001) { 695 base::RandDouble() < .00001) {
696 static int dump_times = 0; 696 static int dump_times = 0;
697 if (dump_times < 5) { 697 if (dump_times < 5) {
698 char url_copy[256] = {0}; 698 char url_copy[256] = {0};
699 strncpy(url_copy, url().spec().c_str(), sizeof(url_copy)); 699 strncpy(url_copy, url().spec().c_str(), sizeof(url_copy));
700 base::debug::Alias(&url_copy); 700 base::debug::Alias(&url_copy);
701 base::debug::Alias(&request_time); 701 base::debug::Alias(&request_time);
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
992 --redirect_limit_; 992 --redirect_limit_;
993 993
994 Start(); 994 Start();
995 return OK; 995 return OK;
996 } 996 }
997 997
998 const URLRequestContext* URLRequest::context() const { 998 const URLRequestContext* URLRequest::context() const {
999 return context_; 999 return context_;
1000 } 1000 }
1001 1001
1002 int64 URLRequest::GetExpectedContentSize() const { 1002 int64_t URLRequest::GetExpectedContentSize() const {
1003 int64 expected_content_size = -1; 1003 int64_t expected_content_size = -1;
1004 if (job_.get()) 1004 if (job_.get())
1005 expected_content_size = job_->expected_content_size(); 1005 expected_content_size = job_->expected_content_size();
1006 1006
1007 return expected_content_size; 1007 return expected_content_size;
1008 } 1008 }
1009 1009
1010 void URLRequest::SetPriority(RequestPriority priority) { 1010 void URLRequest::SetPriority(RequestPriority priority) {
1011 DCHECK_GE(priority, MINIMUM_PRIORITY); 1011 DCHECK_GE(priority, MINIMUM_PRIORITY);
1012 DCHECK_LE(priority, MAXIMUM_PRIORITY); 1012 DCHECK_LE(priority, MAXIMUM_PRIORITY);
1013 1013
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
1216 } 1216 }
1217 1217
1218 void URLRequest::GetConnectionAttempts(ConnectionAttempts* out) const { 1218 void URLRequest::GetConnectionAttempts(ConnectionAttempts* out) const {
1219 if (job_) 1219 if (job_)
1220 job_->GetConnectionAttempts(out); 1220 job_->GetConnectionAttempts(out);
1221 else 1221 else
1222 out->clear(); 1222 out->clear();
1223 } 1223 }
1224 1224
1225 } // namespace net 1225 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698