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

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

Issue 2910473005: Deprecate NonThreadSafe in net/ in favor of SequenceChecker/ThreadChecker. (Closed)
Patch Set: rebase on r476634 Created 3 years, 6 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 unified diff | Download patch
« no previous file with comments | « net/url_request/url_request_throttler_manager.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_throttler_manager.h" 5 #include "net/url_request/url_request_throttler_manager.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "net/base/url_util.h" 9 #include "net/base/url_util.h"
10 #include "net/log/net_log.h" 10 #include "net/log/net_log.h"
(...skipping 13 matching lines...) Expand all
24 url_id_replacements_.ClearPassword(); 24 url_id_replacements_.ClearPassword();
25 url_id_replacements_.ClearUsername(); 25 url_id_replacements_.ClearUsername();
26 url_id_replacements_.ClearQuery(); 26 url_id_replacements_.ClearQuery();
27 url_id_replacements_.ClearRef(); 27 url_id_replacements_.ClearRef();
28 28
29 NetworkChangeNotifier::AddIPAddressObserver(this); 29 NetworkChangeNotifier::AddIPAddressObserver(this);
30 NetworkChangeNotifier::AddConnectionTypeObserver(this); 30 NetworkChangeNotifier::AddConnectionTypeObserver(this);
31 } 31 }
32 32
33 URLRequestThrottlerManager::~URLRequestThrottlerManager() { 33 URLRequestThrottlerManager::~URLRequestThrottlerManager() {
34 DCHECK_CALLED_ON_VALID_THREAD(thread_checker_);
34 NetworkChangeNotifier::RemoveIPAddressObserver(this); 35 NetworkChangeNotifier::RemoveIPAddressObserver(this);
35 NetworkChangeNotifier::RemoveConnectionTypeObserver(this); 36 NetworkChangeNotifier::RemoveConnectionTypeObserver(this);
36 37
37 // Since the manager object might conceivably go away before the 38 // Since the manager object might conceivably go away before the
38 // entries, detach the entries' back-pointer to the manager. 39 // entries, detach the entries' back-pointer to the manager.
39 UrlEntryMap::iterator i = url_entries_.begin(); 40 UrlEntryMap::iterator i = url_entries_.begin();
40 while (i != url_entries_.end()) { 41 while (i != url_entries_.end()) {
41 if (i->second.get() != NULL) { 42 if (i->second.get() != NULL) {
42 i->second->DetachManager(); 43 i->second->DetachManager();
43 } 44 }
44 ++i; 45 ++i;
45 } 46 }
46 47
47 // Delete all entries. 48 // Delete all entries.
48 url_entries_.clear(); 49 url_entries_.clear();
49 } 50 }
50 51
51 scoped_refptr<URLRequestThrottlerEntryInterface> 52 scoped_refptr<URLRequestThrottlerEntryInterface>
52 URLRequestThrottlerManager::RegisterRequestUrl(const GURL &url) { 53 URLRequestThrottlerManager::RegisterRequestUrl(const GURL &url) {
53 DCHECK(!enable_thread_checks_ || CalledOnValidThread()); 54 #if DCHECK_IS_ON()
55 DCHECK(!enable_thread_checks_ || thread_checker_.CalledOnValidThread());
56 #endif
54 57
55 // Normalize the url. 58 // Normalize the url.
56 std::string url_id = GetIdFromUrl(url); 59 std::string url_id = GetIdFromUrl(url);
57 60
58 // Periodically garbage collect old entries. 61 // Periodically garbage collect old entries.
59 GarbageCollectEntriesIfNecessary(); 62 GarbageCollectEntriesIfNecessary();
60 63
61 // Find the entry in the map or create a new NULL entry. 64 // Find the entry in the map or create a new NULL entry.
62 scoped_refptr<URLRequestThrottlerEntry>& entry = url_entries_[url_id]; 65 scoped_refptr<URLRequestThrottlerEntry>& entry = url_entries_[url_id];
63 66
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 void URLRequestThrottlerManager::OnNetworkChange() { 178 void URLRequestThrottlerManager::OnNetworkChange() {
176 // Remove all entries. Any entries that in-flight requests have a reference 179 // Remove all entries. Any entries that in-flight requests have a reference
177 // to will live until those requests end, and these entries may be 180 // to will live until those requests end, and these entries may be
178 // inconsistent with new entries for the same URLs, but since what we 181 // inconsistent with new entries for the same URLs, but since what we
179 // want is a clean slate for the new connection type, this is OK. 182 // want is a clean slate for the new connection type, this is OK.
180 url_entries_.clear(); 183 url_entries_.clear();
181 requests_since_last_gc_ = 0; 184 requests_since_last_gc_ = 0;
182 } 185 }
183 186
184 } // namespace net 187 } // namespace net
OLDNEW
« no previous file with comments | « net/url_request/url_request_throttler_manager.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698