Chromium Code Reviews| Index: chrome/browser/background/background_contents_service.h |
| diff --git a/chrome/browser/background/background_contents_service.h b/chrome/browser/background/background_contents_service.h |
| index 0d99a92bfa02024994266a5295ff8b83db5c6abe..b2e823628a063c007b4e920489fae7f55d9b2de3 100644 |
| --- a/chrome/browser/background/background_contents_service.h |
| +++ b/chrome/browser/background/background_contents_service.h |
| @@ -6,12 +6,17 @@ |
| #define CHROME_BROWSER_BACKGROUND_BACKGROUND_CONTENTS_SERVICE_H_ |
| #include <map> |
| +#include <queue> |
| +#include <set> |
| #include <string> |
| #include <vector> |
| #include "base/gtest_prod_util.h" |
| #include "base/memory/ref_counted.h" |
| +#include "base/memory/weak_ptr.h" |
| +#include "base/time/time.h" |
| #include "chrome/browser/tab_contents/background_contents.h" |
| +#include "chrome/common/extensions/extension.h" |
| #include "components/browser_context_keyed_service/browser_context_keyed_service.h" |
| #include "content/public/browser/notification_observer.h" |
| #include "content/public/browser/notification_registrar.h" |
| @@ -52,6 +57,12 @@ class BackgroundContentsService : private content::NotificationObserver, |
| BackgroundContentsService(Profile* profile, const CommandLine* command_line); |
| virtual ~BackgroundContentsService(); |
| + // Allows tests to reduce the time between a force-installed app/extension |
| + // crashing and when we reload it, and the amount of time we wait for further |
| + // crashes before showing a balloon saying the app/extension is misbehaving. |
| + static void SetCrashDelaysForForceInstalledAppsAndExtensionsForTesting( |
| + int restart_delay_in_ms, int crash_window_in_ms); |
| + |
| // Returns the BackgroundContents associated with the passed application id, |
| // or NULL if none. |
| BackgroundContents* GetAppBackgroundContents(const string16& appid); |
| @@ -121,6 +132,14 @@ class BackgroundContentsService : private content::NotificationObserver, |
| const content::NotificationSource& source, |
| const content::NotificationDetails& details) OVERRIDE; |
| + // Restarts a force-installed app/extension after a crash. Notifies user if |
| + // crash recurs frequently. |
| + void RestartForceInstalledExtensionOnCrash( |
| + const extensions::Extension* extension, Profile* profile); |
| + |
| + // Reloads the extension with the given id. |
| + void ReloadExtension(const std::string& extension_id, Profile* profile); |
| + |
| // Loads all registered BackgroundContents at startup. |
| void LoadBackgroundContentsFromPrefs(Profile* profile); |
| @@ -170,6 +189,15 @@ class BackgroundContentsService : private content::NotificationObserver, |
| // set of background apps as new background contents are opened/closed). |
| void SendChangeNotification(Profile* profile); |
| + // Delay (in ms) before restarting a force-installed extension that crashed. |
| + static int restart_delay_in_ms_; |
| + |
| + // When a force-installed app/extension crashes, we check if it's in a crash/ |
| + // reload loop by checking if the number of crashes exceeds a threshold in a |
| + // given time window. The duration of that window is given by |
|
bartfab (slow)
2013/08/27 19:21:31
Nit: Add a colon at the end of the sentence.
anitawoodruff
2013/08/28 09:03:06
Done.
|
| + // kMisbehaveCrashCountThreshold * (restart_delay_in_ms + crash_window_in_ms) |
| + static int crash_window_in_ms_; |
| + |
| // PrefService used to store list of background pages (or NULL if this is |
| // running under an incognito profile). |
| PrefService* prefs_; |
| @@ -190,6 +218,18 @@ class BackgroundContentsService : private content::NotificationObserver, |
| typedef std::map<string16, BackgroundContentsInfo> BackgroundContentsMap; |
| BackgroundContentsMap contents_map_; |
| + // Map associating IDs of force-installed extensions/apps with their most |
| + // recent crash timestamps. |
| + // Key: app/extension id. |
| + // Value: queue containing up to 5 most recent crash timestamps. |
| + std::map<std::string, std::queue<base::TimeTicks> > extension_crashlog_map_; |
| + |
| + // Map containing ids of force-installed apps/extensions for which we have |
| + // already shown an 'App/Extension is misbehaving' balloon. |
| + std::set<std::string> misbehaving_extensions_; |
| + |
| + base::WeakPtrFactory<BackgroundContentsService> weak_factory_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(BackgroundContentsService); |
| }; |