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

Side by Side Diff: chrome/browser/background/background_contents_service.h

Issue 2310463002: Update component extension reload backoff logic. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes per wez@'s comments. Created 4 years, 3 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 CHROME_BROWSER_BACKGROUND_BACKGROUND_CONTENTS_SERVICE_H_ 5 #ifndef CHROME_BROWSER_BACKGROUND_BACKGROUND_CONTENTS_SERVICE_H_
6 #define CHROME_BROWSER_BACKGROUND_BACKGROUND_CONTENTS_SERVICE_H_ 6 #define CHROME_BROWSER_BACKGROUND_BACKGROUND_CONTENTS_SERVICE_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
11 #include <string> 11 #include <string>
12 #include <vector> 12 #include <vector>
13 13
14 #include "base/gtest_prod_util.h" 14 #include "base/gtest_prod_util.h"
15 #include "base/macros.h" 15 #include "base/macros.h"
16 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
17 #include "base/memory/weak_ptr.h"
17 #include "base/scoped_observer.h" 18 #include "base/scoped_observer.h"
18 #include "chrome/browser/background/background_contents.h" 19 #include "chrome/browser/background/background_contents.h"
19 #include "components/keyed_service/core/keyed_service.h" 20 #include "components/keyed_service/core/keyed_service.h"
20 #include "content/public/browser/notification_observer.h" 21 #include "content/public/browser/notification_observer.h"
21 #include "content/public/browser/notification_registrar.h" 22 #include "content/public/browser/notification_registrar.h"
22 #include "content/public/common/window_container_type.h" 23 #include "content/public/common/window_container_type.h"
23 #include "extensions/browser/extension_registry_observer.h" 24 #include "extensions/browser/extension_registry_observer.h"
24 #include "net/base/backoff_entry.h" 25 #include "net/base/backoff_entry.h"
25 #include "ui/base/window_open_disposition.h" 26 #include "ui/base/window_open_disposition.h"
26 #include "url/gurl.h" 27 #include "url/gurl.h"
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 void ShutdownAssociatedBackgroundContents(const base::string16& appid); 210 void ShutdownAssociatedBackgroundContents(const base::string16& appid);
210 211
211 // Returns true if this BackgroundContents is in the contents_list_. 212 // Returns true if this BackgroundContents is in the contents_list_.
212 bool IsTracked(BackgroundContents* contents) const; 213 bool IsTracked(BackgroundContents* contents) const;
213 214
214 // Sends out a notification when our association of background contents with 215 // Sends out a notification when our association of background contents with
215 // apps may have changed (used by BackgroundApplicationListModel to update the 216 // apps may have changed (used by BackgroundApplicationListModel to update the
216 // set of background apps as new background contents are opened/closed). 217 // set of background apps as new background contents are opened/closed).
217 void SendChangeNotification(Profile* profile); 218 void SendChangeNotification(Profile* profile);
218 219
220 // Checks whether there has been additional |extension_id| failures. If not,
221 // delete the BackoffEntry corresponding to |extension_id|, if exists.
222 void MaybeClearBackoffEntry(const std::string extension_id,
223 int expected_failure_count);
224
219 // Delay (in ms) before restarting a force-installed extension that crashed. 225 // Delay (in ms) before restarting a force-installed extension that crashed.
220 static int restart_delay_in_ms_; 226 static int restart_delay_in_ms_;
221 227
222 // PrefService used to store list of background pages (or NULL if this is 228 // PrefService used to store list of background pages (or NULL if this is
223 // running under an incognito profile). 229 // running under an incognito profile).
224 PrefService* prefs_; 230 PrefService* prefs_;
225 content::NotificationRegistrar registrar_; 231 content::NotificationRegistrar registrar_;
226 232
227 // Information we track about each BackgroundContents. 233 // Information we track about each BackgroundContents.
228 struct BackgroundContentsInfo { 234 struct BackgroundContentsInfo {
229 // The BackgroundContents whose information we are tracking. 235 // The BackgroundContents whose information we are tracking.
230 BackgroundContents* contents; 236 BackgroundContents* contents;
231 // The name of the top level frame for this BackgroundContents. 237 // The name of the top level frame for this BackgroundContents.
232 std::string frame_name; 238 std::string frame_name;
233 }; 239 };
234 240
235 // Map associating currently loaded BackgroundContents with their parent 241 // Map associating currently loaded BackgroundContents with their parent
236 // applications. 242 // applications.
237 // Key: application id 243 // Key: application id
238 // Value: BackgroundContentsInfo for the BC associated with that application 244 // Value: BackgroundContentsInfo for the BC associated with that application
239 typedef std::map<base::string16, BackgroundContentsInfo> 245 typedef std::map<base::string16, BackgroundContentsInfo>
240 BackgroundContentsMap; 246 BackgroundContentsMap;
241 BackgroundContentsMap contents_map_; 247 BackgroundContentsMap contents_map_;
242 248
243 // Map associating component extensions that have attempted to reload with a 249 // Map associating component extensions that have attempted to reload with a
244 // BackoffEntry keeping track of retry timing. 250 // BackoffEntry keeping track of retry timing.
245 typedef std::map<extensions::ExtensionId, std::unique_ptr<net::BackoffEntry>> 251 typedef std::map<extensions::ExtensionId, std::unique_ptr<net::BackoffEntry>>
246 ExtensionBackoffEntryMap; 252 ComponentExtensionBackoffEntryMap;
247 ExtensionBackoffEntryMap backoff_map_; 253 ComponentExtensionBackoffEntryMap component_backoff_map_;
248 254
249 ScopedObserver<extensions::ExtensionRegistry, 255 ScopedObserver<extensions::ExtensionRegistry,
250 extensions::ExtensionRegistryObserver> 256 extensions::ExtensionRegistryObserver>
251 extension_registry_observer_; 257 extension_registry_observer_;
252 258
259 base::WeakPtrFactory<BackgroundContentsService> weak_ptr_factory_;
260
253 DISALLOW_COPY_AND_ASSIGN(BackgroundContentsService); 261 DISALLOW_COPY_AND_ASSIGN(BackgroundContentsService);
254 }; 262 };
255 263
256 #endif // CHROME_BROWSER_BACKGROUND_BACKGROUND_CONTENTS_SERVICE_H_ 264 #endif // CHROME_BROWSER_BACKGROUND_BACKGROUND_CONTENTS_SERVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698