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..6d3001b79d873dcf9780a8ab165044cc4b24413f 100644 |
| --- a/chrome/browser/background/background_contents_service.h |
| +++ b/chrome/browser/background/background_contents_service.h |
| @@ -6,12 +6,16 @@ |
| #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/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 +56,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 notification that the app is misbehaving. |
|
anitawoodruff
2013/08/27 09:05:36
*'app/extension', not 'app'- will fix
anitawoodruff
2013/08/27 09:13:03
Done.
|
| + static void SetCrashDelaysForForceInstalledAppsAndExtensionsForTesting( |
| + const int restart_delay_millis, const int crash_window_millis); |
|
bartfab (slow)
2013/08/27 09:21:29
Nit: We tend to use "_in_ms" instead of "_millis".
anitawoodruff
2013/08/27 11:57:39
Done.
|
| + |
| // Returns the BackgroundContents associated with the passed application id, |
| // or NULL if none. |
| BackgroundContents* GetAppBackgroundContents(const string16& appid); |
| @@ -170,6 +180,21 @@ class BackgroundContentsService : private content::NotificationObserver, |
| // set of background apps as new background contents are opened/closed). |
| void SendChangeNotification(Profile* profile); |
| + // Restarts a force-installed app/extension after a crash. Notifies user if |
| + // crash recurs frequently. |
| + void RestartForceInstalledExtensionOnCrash( |
| + const extensions::Extension* extension, Profile* profile); |
| + |
| + // Delay (in ms) before restarting a force-installed extension that crashed. |
| + static int restart_delay_millis_; |
| + |
| + // When a force-installed extension/app crashes, we check if it's in a crash/ |
|
bartfab (slow)
2013/08/27 09:21:29
Nit: Some comments say "app/extension," others say
anitawoodruff
2013/08/27 11:57:39
Done.
|
| + // reload loop by counting how many times it crashed in a given time window. |
| + // The duration of that window is calculated by multiplying this value by |
| + // the maximum number of crashes and adding on the restart delay * max number |
| + // of crashes. |
|
anitawoodruff
2013/08/27 09:05:36
This is the verbose description moved from the .cc
bartfab (slow)
2013/08/27 11:20:14
I think it is clear.
|
| + static int crash_window_millis_; |
| + |
| // PrefService used to store list of background pages (or NULL if this is |
| // running under an incognito profile). |
| PrefService* prefs_; |
| @@ -190,6 +215,16 @@ 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: extension/app 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_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(BackgroundContentsService); |
| }; |