OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/callback.h" | 8 #include "base/callback.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/lazy_instance.h" |
10 #include "base/memory/singleton.h" | 11 #include "base/memory/singleton.h" |
11 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
12 #include "base/metrics/stats_counters.h" | 13 #include "base/metrics/stats_counters.h" |
13 #include "base/synchronization/lock.h" | 14 #include "base/synchronization/lock.h" |
14 #include "net/base/auth.h" | 15 #include "net/base/auth.h" |
15 #include "net/base/host_port_pair.h" | 16 #include "net/base/host_port_pair.h" |
16 #include "net/base/load_flags.h" | 17 #include "net/base/load_flags.h" |
17 #include "net/base/net_errors.h" | 18 #include "net/base/net_errors.h" |
18 #include "net/base/net_log.h" | 19 #include "net/base/net_log.h" |
19 #include "net/base/network_delegate.h" | 20 #include "net/base/network_delegate.h" |
(...skipping 28 matching lines...) Expand all Loading... |
48 headers->RemoveHeader(HttpRequestHeaders::kContentType); | 49 headers->RemoveHeader(HttpRequestHeaders::kContentType); |
49 headers->RemoveHeader(HttpRequestHeaders::kOrigin); | 50 headers->RemoveHeader(HttpRequestHeaders::kOrigin); |
50 } | 51 } |
51 | 52 |
52 // TODO(battre): Delete this, see http://crbug.com/89321: | 53 // TODO(battre): Delete this, see http://crbug.com/89321: |
53 // This counter keeps track of the identifiers used for URL requests so far. | 54 // This counter keeps track of the identifiers used for URL requests so far. |
54 // 0 is reserved to represent an invalid ID. | 55 // 0 is reserved to represent an invalid ID. |
55 uint64 g_next_url_request_identifier = 1; | 56 uint64 g_next_url_request_identifier = 1; |
56 | 57 |
57 // This lock protects g_next_url_request_identifier. | 58 // This lock protects g_next_url_request_identifier. |
58 base::Lock g_next_url_request_identifier_lock; | 59 base::LazyInstance<base::Lock, |
| 60 base::LeakyLazyInstanceTraits<base::Lock> > |
| 61 g_next_url_request_identifier_lock(base::LINKER_INITIALIZED); |
59 | 62 |
60 // Returns an prior unused identifier for URL requests. | 63 // Returns an prior unused identifier for URL requests. |
61 uint64 GenerateURLRequestIdentifier() { | 64 uint64 GenerateURLRequestIdentifier() { |
62 base::AutoLock lock(g_next_url_request_identifier_lock); | 65 base::AutoLock lock(g_next_url_request_identifier_lock.Get()); |
63 return g_next_url_request_identifier++; | 66 return g_next_url_request_identifier++; |
64 } | 67 } |
65 | 68 |
66 } // namespace | 69 } // namespace |
67 | 70 |
68 URLRequest::ProtocolFactory* | 71 URLRequest::ProtocolFactory* |
69 URLRequest::Deprecated::RegisterProtocolFactory(const std::string& scheme, | 72 URLRequest::Deprecated::RegisterProtocolFactory(const std::string& scheme, |
70 ProtocolFactory* factory) { | 73 ProtocolFactory* factory) { |
71 return URLRequest::RegisterProtocolFactory(scheme, factory); | 74 return URLRequest::RegisterProtocolFactory(scheme, factory); |
72 } | 75 } |
(...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
889 | 892 |
890 void URLRequest::SetUnblockedOnDelegate() { | 893 void URLRequest::SetUnblockedOnDelegate() { |
891 if (!blocked_on_delegate_) | 894 if (!blocked_on_delegate_) |
892 return; | 895 return; |
893 blocked_on_delegate_ = false; | 896 blocked_on_delegate_ = false; |
894 load_state_param_.clear(); | 897 load_state_param_.clear(); |
895 net_log_.EndEvent(NetLog::TYPE_URL_REQUEST_BLOCKED_ON_DELEGATE, NULL); | 898 net_log_.EndEvent(NetLog::TYPE_URL_REQUEST_BLOCKED_ON_DELEGATE, NULL); |
896 } | 899 } |
897 | 900 |
898 } // namespace net | 901 } // namespace net |
OLD | NEW |