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..e1d21c527b4291580d81b90150f4617a73104ef0 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 balloon saying the app/extension is misbehaving. |
+ static void SetCrashDelaysForForceInstalledAppsAndExtensionsForTesting( |
+ const int restart_delay_in_ms, const int crash_window_in_ms); |
bartfab (slow)
2013/08/27 15:37:44
Nit: The const is very much correct here but not c
anitawoodruff
2013/08/27 17:34:29
Done.
|
+ |
// Returns the BackgroundContents associated with the passed application id, |
// or NULL if none. |
BackgroundContents* GetAppBackgroundContents(const string16& appid); |
@@ -170,6 +180,24 @@ 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); |
bartfab (slow)
2013/08/27 15:37:44
Here, the const definitely should stay as we are d
|
+ |
+ // Reloads the extension with the given id. |
+ void ReloadExtension(const std::string extension_id, Profile* profile); |
bartfab (slow)
2013/08/27 15:37:44
Nit: Pass the string by const reference.
anitawoodruff
2013/08/27 17:34:29
Done.
|
+ |
+ // Delay (in ms) before restarting a force-installed extension that crashed. |
+ static int restart_delay_millis_; |
bartfab (slow)
2013/08/27 15:37:44
Nit: s/millis/in_ms/
anitawoodruff
2013/08/27 17:34:29
Done.
|
+ |
+ // 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 calculated by multiplying |
+ // |crash_window_millis_| by the threshold crash count and adding on the |
bartfab (slow)
2013/08/27 15:37:44
Nit 1: s/millis/in_ms/
Nit 2: The prose is fine.
anitawoodruff
2013/08/27 17:34:29
Done.
|
+ // restart delay * threshold crash count. |
+ static int crash_window_millis_; |
bartfab (slow)
2013/08/27 15:37:44
Nit: s/millis/in_ms/
anitawoodruff
2013/08/27 17:34:29
Done.
|
+ |
// 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_; |
bartfab (slow)
2013/08/27 15:37:44
Nit: #include "base/memory/weak_ptr.h"
anitawoodruff
2013/08/27 17:34:29
Done.
|
+ |
DISALLOW_COPY_AND_ASSIGN(BackgroundContentsService); |
}; |