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

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

Issue 1909773002: Convert //extensions/browser from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 years, 8 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 <string> 10 #include <string>
10 11
11 #include "base/macros.h" 12 #include "base/macros.h"
12 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "base/threading/non_thread_safe.h" 14 #include "base/threading/non_thread_safe.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;
(...skipping 18 matching lines...) Expand all
42 class ExtensionThrottleManager 42 class ExtensionThrottleManager
43 : NON_EXPORTED_BASE(public base::NonThreadSafe), 43 : NON_EXPORTED_BASE(public base::NonThreadSafe),
44 public net::NetworkChangeNotifier::IPAddressObserver, 44 public net::NetworkChangeNotifier::IPAddressObserver,
45 public net::NetworkChangeNotifier::ConnectionTypeObserver { 45 public net::NetworkChangeNotifier::ConnectionTypeObserver {
46 public: 46 public:
47 ExtensionThrottleManager(); 47 ExtensionThrottleManager();
48 ~ExtensionThrottleManager() override; 48 ~ExtensionThrottleManager() override;
49 49
50 // Creates a content::ResourceThrottle for |request| to prevent extensions 50 // Creates a content::ResourceThrottle for |request| to prevent extensions
51 // from requesting a URL too often, if such a throttle is needed. 51 // from requesting a URL too often, if such a throttle is needed.
52 scoped_ptr<content::ResourceThrottle> MaybeCreateThrottle( 52 std::unique_ptr<content::ResourceThrottle> MaybeCreateThrottle(
53 const net::URLRequest* request); 53 const net::URLRequest* request);
54 54
55 // TODO(xunjieli): Remove this method and replace with 55 // TODO(xunjieli): Remove this method and replace with
56 // ShouldRejectRequest(request) and UpdateWithResponse(request, status_code), 56 // ShouldRejectRequest(request) and UpdateWithResponse(request, status_code),
57 // which will also allow ExtensionThrottleEntry to no longer be reference 57 // which will also allow ExtensionThrottleEntry to no longer be reference
58 // counted, and ExtensionThrottleEntryInterface to be removed. 58 // counted, and ExtensionThrottleEntryInterface to be removed.
59 59
60 // Must be called for every request, returns the URL request throttler entry 60 // Must be called for every request, returns the URL request throttler entry
61 // associated with the URL. The caller must inform this entry of some events. 61 // associated with the URL. The caller must inform this entry of some events.
62 // Please refer to extension_throttle_entry_interface.h for further 62 // Please refer to extension_throttle_entry_interface.h for further
63 // informations. 63 // informations.
64 scoped_refptr<ExtensionThrottleEntryInterface> RegisterRequestUrl( 64 scoped_refptr<ExtensionThrottleEntryInterface> RegisterRequestUrl(
65 const GURL& url); 65 const GURL& url);
66 66
67 void SetBackoffPolicyForTests(scoped_ptr<net::BackoffEntry::Policy> policy); 67 void SetBackoffPolicyForTests(
68 std::unique_ptr<net::BackoffEntry::Policy> policy);
68 69
69 // Registers a new entry in this service and overrides the existing entry (if 70 // Registers a new entry in this service and overrides the existing entry (if
70 // any) for the URL. The service will hold a reference to the entry. 71 // any) for the URL. The service will hold a reference to the entry.
71 // It is only used by unit tests. 72 // It is only used by unit tests.
72 void OverrideEntryForTests(const GURL& url, ExtensionThrottleEntry* entry); 73 void OverrideEntryForTests(const GURL& url, ExtensionThrottleEntry* entry);
73 74
74 // Explicitly erases an entry. 75 // Explicitly erases an entry.
75 // This is useful to remove those entries which have got infinite lifetime and 76 // This is useful to remove those entries which have got infinite lifetime and
76 // thus won't be garbage collected. 77 // thus won't be garbage collected.
77 // It is only used by unit tests. 78 // It is only used by unit tests.
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 169
169 // net::NetLog to use, if configured. 170 // net::NetLog to use, if configured.
170 net::BoundNetLog net_log_; 171 net::BoundNetLog net_log_;
171 172
172 // Valid once we've registered for network notifications. 173 // Valid once we've registered for network notifications.
173 base::PlatformThreadId registered_from_thread_; 174 base::PlatformThreadId registered_from_thread_;
174 175
175 bool ignore_user_gesture_load_flag_for_tests_; 176 bool ignore_user_gesture_load_flag_for_tests_;
176 177
177 // This is NULL when it is not set for tests. 178 // This is NULL when it is not set for tests.
178 scoped_ptr<net::BackoffEntry::Policy> backoff_policy_for_tests_; 179 std::unique_ptr<net::BackoffEntry::Policy> backoff_policy_for_tests_;
179 180
180 DISALLOW_COPY_AND_ASSIGN(ExtensionThrottleManager); 181 DISALLOW_COPY_AND_ASSIGN(ExtensionThrottleManager);
181 }; 182 };
182 183
183 } // namespace extensions 184 } // namespace extensions
184 185
185 #endif // EXTENSIONS_BROWSER_EXTENSION_THROTTLE_MANAGER_H_ 186 #endif // EXTENSIONS_BROWSER_EXTENSION_THROTTLE_MANAGER_H_
OLDNEW
« no previous file with comments | « extensions/browser/extension_throttle_entry.cc ('k') | extensions/browser/extension_throttle_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698