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

Side by Side Diff: extensions/browser/extension_throttle_manager.h

Issue 2915523002: Replace deprecated base::NonThreadSafe in extensions in favor of SequenceChecker. (Closed)
Patch Set: Add TestBrowserThreadBundle 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
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 #ifndef EXTENSIONS_BROWSER_EXTENSION_THROTTLE_MANAGER_H_ 5 #ifndef EXTENSIONS_BROWSER_EXTENSION_THROTTLE_MANAGER_H_
6 #define EXTENSIONS_BROWSER_EXTENSION_THROTTLE_MANAGER_H_ 6 #define EXTENSIONS_BROWSER_EXTENSION_THROTTLE_MANAGER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <memory> 9 #include <memory>
10 #include <string> 10 #include <string>
11 11
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/threading/non_thread_safe.h" 14 #include "base/sequence_checker.h"
15 #include "base/threading/platform_thread.h" 15 #include "base/threading/platform_thread.h"
16 #include "extensions/browser/extension_throttle_entry.h" 16 #include "extensions/browser/extension_throttle_entry.h"
17 #include "net/base/backoff_entry.h" 17 #include "net/base/backoff_entry.h"
18 #include "net/base/net_export.h" 18 #include "net/base/net_export.h"
19 #include "net/base/network_change_notifier.h" 19 #include "net/base/network_change_notifier.h"
20 #include "url/gurl.h" 20 #include "url/gurl.h"
21 21
22 namespace content { 22 namespace content {
23 class ResourceThrottle; 23 class ResourceThrottle;
24 } 24 }
25 25
26 namespace net { 26 namespace net {
27 class NetLog; 27 class NetLog;
28 class NetLogWithSource; 28 class NetLogWithSource;
29 } 29 }
30 30
31 namespace extensions { 31 namespace extensions {
32 32
33 // Class that registers URL request throttler entries for URLs being accessed 33 // Class that registers URL request throttler entries for URLs being accessed
34 // in order to supervise traffic. URL requests for HTTP contents should 34 // in order to supervise traffic. URL requests for HTTP contents should
35 // register their URLs in this manager on each request. 35 // register their URLs in this manager on each request.
36 // 36 //
37 // ExtensionThrottleManager maintains a map of URL IDs to URL request 37 // ExtensionThrottleManager maintains a map of URL IDs to URL request
38 // throttler entries. It creates URL request throttler entries when new URLs 38 // throttler entries. It creates URL request throttler entries when new URLs
39 // are registered, and does garbage collection from time to time in order to 39 // are registered, and does garbage collection from time to time in order to
40 // clean out outdated entries. URL ID consists of lowercased scheme, host, port 40 // clean out outdated entries. URL ID consists of lowercased scheme, host, port
41 // and path. All URLs converted to the same ID will share the same entry. 41 // and path. All URLs converted to the same ID will share the same entry.
42 class ExtensionThrottleManager 42 class ExtensionThrottleManager
43 : NON_EXPORTED_BASE(public base::NonThreadSafe), 43 : public net::NetworkChangeNotifier::IPAddressObserver,
44 public net::NetworkChangeNotifier::IPAddressObserver,
45 public net::NetworkChangeNotifier::ConnectionTypeObserver { 44 public net::NetworkChangeNotifier::ConnectionTypeObserver {
46 public: 45 public:
47 ExtensionThrottleManager(); 46 ExtensionThrottleManager();
48 ~ExtensionThrottleManager() override; 47 ~ExtensionThrottleManager() override;
49 48
50 // Creates a content::ResourceThrottle for |request| to prevent extensions 49 // Creates a content::ResourceThrottle for |request| to prevent extensions
51 // from requesting a URL too often, if such a throttle is needed. 50 // from requesting a URL too often, if such a throttle is needed.
52 std::unique_ptr<content::ResourceThrottle> MaybeCreateThrottle( 51 std::unique_ptr<content::ResourceThrottle> MaybeCreateThrottle(
53 const net::URLRequest* request); 52 const net::URLRequest* request);
54 53
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 net::NetLogWithSource net_log_; 170 net::NetLogWithSource net_log_;
172 171
173 // Valid once we've registered for network notifications. 172 // Valid once we've registered for network notifications.
174 base::PlatformThreadId registered_from_thread_; 173 base::PlatformThreadId registered_from_thread_;
175 174
176 bool ignore_user_gesture_load_flag_for_tests_; 175 bool ignore_user_gesture_load_flag_for_tests_;
177 176
178 // This is NULL when it is not set for tests. 177 // This is NULL when it is not set for tests.
179 std::unique_ptr<net::BackoffEntry::Policy> backoff_policy_for_tests_; 178 std::unique_ptr<net::BackoffEntry::Policy> backoff_policy_for_tests_;
180 179
180 SEQUENCE_CHECKER(sequence_checker_);
181
181 DISALLOW_COPY_AND_ASSIGN(ExtensionThrottleManager); 182 DISALLOW_COPY_AND_ASSIGN(ExtensionThrottleManager);
182 }; 183 };
183 184
184 } // namespace extensions 185 } // namespace extensions
185 186
186 #endif // EXTENSIONS_BROWSER_EXTENSION_THROTTLE_MANAGER_H_ 187 #endif // EXTENSIONS_BROWSER_EXTENSION_THROTTLE_MANAGER_H_
OLDNEW
« no previous file with comments | « extensions/browser/api/api_resource_manager.h ('k') | extensions/browser/extension_throttle_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698