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

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

Issue 6599004: Modify ThreadChecker and NonThreadSafe so that their functionality is (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: update copyright year for new/moved files Created 9 years, 9 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 | Annotate | Revision Log
« 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 <list> 7 #include <list>
8 8
9 // TODO(joi): Remove once crbug.com/71721 is fixed. 9 // TODO(joi): Remove once crbug.com/71721 is fixed.
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 15 matching lines...) Expand all
26 char url[256]; 26 char url[256];
27 27
28 // Not a refptr, we don't want to change behavior by keeping it alive. 28 // Not a refptr, we don't want to change behavior by keeping it alive.
29 net::URLRequestThrottlerEntryInterface* entry; 29 net::URLRequestThrottlerEntryInterface* entry;
30 }; 30 };
31 31
32 } // namespace 32 } // namespace
33 33
34 namespace net { 34 namespace net {
35 35
36 ThreadCheckerForRelease::ThreadCheckerForRelease()
37 : valid_thread_id_(base::kInvalidThreadId) {
38 EnsureThreadIdAssigned();
39 }
40
41 ThreadCheckerForRelease::~ThreadCheckerForRelease() {}
42
43 bool ThreadCheckerForRelease::CalledOnValidThread() const {
44 EnsureThreadIdAssigned();
45 base::AutoLock auto_lock(lock_);
46 return valid_thread_id_ == base::PlatformThread::CurrentId();
47 }
48
49 void ThreadCheckerForRelease::DetachFromThread() {
50 base::AutoLock auto_lock(lock_);
51 valid_thread_id_ = base::kInvalidThreadId;
52 }
53
54 void ThreadCheckerForRelease::EnsureThreadIdAssigned() const {
55 base::AutoLock auto_lock(lock_);
56 if (valid_thread_id_ != base::kInvalidThreadId)
57 return;
58 valid_thread_id_ = base::PlatformThread::CurrentId();
59 }
60
61 const unsigned int URLRequestThrottlerManager::kMaximumNumberOfEntries = 1500; 36 const unsigned int URLRequestThrottlerManager::kMaximumNumberOfEntries = 1500;
62 const unsigned int URLRequestThrottlerManager::kRequestsBetweenCollecting = 200; 37 const unsigned int URLRequestThrottlerManager::kRequestsBetweenCollecting = 200;
63 38
64 URLRequestThrottlerManager* URLRequestThrottlerManager::GetInstance() { 39 URLRequestThrottlerManager* URLRequestThrottlerManager::GetInstance() {
65 return Singleton<URLRequestThrottlerManager>::get(); 40 return Singleton<URLRequestThrottlerManager>::get();
66 } 41 }
67 42
68 scoped_refptr<URLRequestThrottlerEntryInterface> 43 scoped_refptr<URLRequestThrottlerEntryInterface>
69 URLRequestThrottlerManager::RegisterRequestUrl(const GURL &url) { 44 URLRequestThrottlerManager::RegisterRequestUrl(const GURL &url) {
70 CHECK(being_tested_ || thread_checker_.CalledOnValidThread()); 45 CHECK(being_tested_ || thread_checker_.CalledOnValidThread());
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 183
209 CHECK(nulls_found == 0); 184 CHECK(nulls_found == 0);
210 185
211 // In case something broke we want to make sure not to grow indefinitely. 186 // In case something broke we want to make sure not to grow indefinitely.
212 while (url_entries_.size() > kMaximumNumberOfEntries) { 187 while (url_entries_.size() > kMaximumNumberOfEntries) {
213 url_entries_.erase(url_entries_.begin()); 188 url_entries_.erase(url_entries_.begin());
214 } 189 }
215 } 190 }
216 191
217 } // namespace net 192 } // 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