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

Unified Diff: extensions/browser/api/runtime/runtime_api.h

Issue 1970613003: Add a new app API to enable watchdog behavior restarts in kiosk apps (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unneeded include and forward declare Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
Index: extensions/browser/api/runtime/runtime_api.h
diff --git a/extensions/browser/api/runtime/runtime_api.h b/extensions/browser/api/runtime/runtime_api.h
index 187f7b0d7f16d0fb8e9f60cd2d45c50782e698fb..14d03e0c49505077822e128304bf9a3789d87946 100644
--- a/extensions/browser/api/runtime/runtime_api.h
+++ b/extensions/browser/api/runtime/runtime_api.h
@@ -65,10 +65,19 @@ class RuntimeAPI : public BrowserContextKeyedAPI,
void OpenURL(const GURL& uninstall_url);
bool GetPlatformInfo(api::runtime::PlatformInfo* info);
bool RestartDevice(std::string* error_message);
+
+ using OnWatchdogTimeoutCallback =
+ base::Callback<void(bool success, const std::string& message)>;
+ void RestartDeviceOnWatchdogTimeout(
+ const Extension* extension,
+ int seconds,
+ const OnWatchdogTimeoutCallback& callback);
+
bool OpenOptionsPage(const Extension* extension);
private:
friend class BrowserContextKeyedAPIFactory<RuntimeAPI>;
+ friend class RestartOnWatchdogApiTest;
// ExtensionRegistryObserver implementation.
void OnExtensionLoaded(content::BrowserContext* browser_context,
@@ -81,6 +90,9 @@ class RuntimeAPI : public BrowserContextKeyedAPI,
const Extension* extension,
UninstallReason reason) override;
+ void OnRestartWatchdogTimeout(const Extension* extension,
+ const OnWatchdogTimeoutCallback& callback);
+
// BrowserContextKeyedAPI implementation:
static const char* service_name() { return "RuntimeAPI"; }
static const bool kServiceRedirectedInIncognito = true;
@@ -102,6 +114,10 @@ class RuntimeAPI : public BrowserContextKeyedAPI,
void RemovePendingOnInstallInfoFromPref(const ExtensionId& extension_id);
void StorePendingOnInstallInfoToPref(const Extension* extension);
+ void SetMinDurationBetweenRestartsForTesting(base::TimeDelta delta) {
+ minimum_duration_between_restarts_ = delta;
+ }
+
std::unique_ptr<RuntimeAPIDelegate> delegate_;
content::BrowserContext* browser_context_;
@@ -118,6 +134,13 @@ class RuntimeAPI : public BrowserContextKeyedAPI,
ScopedObserver<ProcessManager, ProcessManagerObserver>
process_manager_observer_;
+ // The timer that will trigger a device restart when it times out.
+ base::OneShotTimer watchdog_timer_;
xiyuan 2016/05/13 17:56:15 nit: #include "base/timer/timer.h"
afakhry 2016/05/14 01:27:35 Done.
+
+ // The minimum allowed duration between two successive restarts on watchdog
+ // timer.
+ base::TimeDelta minimum_duration_between_restarts_;
xiyuan 2016/05/13 17:56:15 nit: #include "base/time/time.h"
afakhry 2016/05/14 01:27:35 Done.
+
DISALLOW_COPY_AND_ASSIGN(RuntimeAPI);
};
@@ -220,6 +243,19 @@ class RuntimeRestartFunction : public UIThreadExtensionFunction {
ResponseAction Run() override;
};
+class RuntimeRestartOnWatchdogFunction : public UIThreadExtensionFunction {
+ public:
+ DECLARE_EXTENSION_FUNCTION("runtime.restartOnWatchdog",
+ RUNTIME_RESTARTONWATCHDOG)
+
+ protected:
+ ~RuntimeRestartOnWatchdogFunction() override {}
+ ResponseAction Run() override;
+
+ private:
+ void OnWatchdogTimeout(bool success, const std::string& message);
+};
+
class RuntimeGetPlatformInfoFunction : public UIThreadExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("runtime.getPlatformInfo",

Powered by Google App Engine
This is Rietveld 408576698