Chromium Code Reviews| Index: chrome/browser/extensions/app_host_installer_win.h |
| diff --git a/chrome/browser/extensions/app_host_installer_win.h b/chrome/browser/extensions/app_host_installer_win.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..6ca7f09bfaf92bf7a5ff6ba5923091464492ecbe |
| --- /dev/null |
| +++ b/chrome/browser/extensions/app_host_installer_win.h |
| @@ -0,0 +1,70 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_EXTENSIONS_APP_HOST_INSTALLER_WIN_H_ |
| +#define CHROME_BROWSER_EXTENSIONS_APP_HOST_INSTALLER_WIN_H_ |
| + |
| +#include "base/basictypes.h" |
| +#include "base/callback_forward.h" |
| +#include "base/win/object_watcher.h" |
| +#include "chrome/browser/extensions/app_host_installer_win.h" |
| +#include "content/public/browser/browser_thread.h" |
| + |
| +namespace extensions { |
| + |
| +class Extension; |
| + |
| +using content::BrowserThread; |
|
grt (UTC plus 2)
2012/11/02 20:44:42
"using" in a header like this is banned.
huangs
2012/11/02 22:15:33
Done (deleted).
|
| + |
| +// Called on the original calling thread after InstallAppHostIfNecessary() |
| +// is complete. A boolean flag is passed, which is false iff the installation |
| +// was required but failed. |
| +typedef base::Callback<void(bool)> OnAppHostInstallationCompleteCallback; |
| + |
| +// Determines if the App Host is installed and, if not, installs it. |
| +class AppHostInstaller { |
|
grt (UTC plus 2)
2012/11/02 20:44:42
why is this class public? consider putting Ensure
erikwright (departed)
2012/11/02 20:48:23
It's lacking unit tests in the current CL. I would
huangs
2012/11/02 22:15:33
Leaving it the way it is (for now).
benwells
2012/11/05 07:44:33
I'd prefer this to all be hidden, and when the tes
|
| + public: |
| + // Asynchronously checks the system state and installs the App Host if not |
| + // present. |completion_callback| will be notified on the caller's thread |
| + // when the installation process completes, and is passed a boolean to |
| + // indicate success or failure of installation. |
| + // No timeout is used - thus |completion_callback| may be held for an |
| + // arbitrarily long time, including past browser shutdown. |
| + static void EnsureAppHostInstalled( |
| + const OnAppHostInstallationCompleteCallback& completion_callback); |
| + |
| + private: |
| + // Constructs an AppHostInstaller, which will call |completion_callback| |
| + // on the specified thread upon installation completion. |
| + AppHostInstaller( |
| + const OnAppHostInstallationCompleteCallback& completion_callback, |
| + BrowserThread::ID caller_thread_id); |
| + |
| + ~AppHostInstaller(); |
| + |
| + // Checks the system state on the FILE thread. Will call |
| + // InstallAppHostOnFileThread() if App Host is not installed. |
| + void EnsureAppHostInstalledInternal(); |
| + |
| + // Runs on the FILE thread. Installs App Host by asynchronously triggering |
| + // App Host installation. Will call FinishOnCallerThread() upon completion |
| + // (successful or otherwise). |
| + void InstallAppHostOnFileThread(); |
| + |
| + // Passes |success| to |completion_callback| on the original caller thread. |
| + // Deletes the AppHostInstaller. |
| + void FinishOnCallerThread(bool success); |
| + |
| + OnAppHostInstallationCompleteCallback completion_callback_; |
| + BrowserThread::ID caller_thread_id_; |
| + base::win::ScopedHandle process_; |
|
erikwright (departed)
2012/11/02 20:40:59
#include "base/win/scoped_handle.h"
huangs
2012/11/02 22:15:33
Done.
|
| + scoped_ptr<base::win::ObjectWatcher::Delegate> delegate_; |
|
erikwright (departed)
2012/11/02 20:40:59
#include "base/memory/scoped_ptr.h"
huangs
2012/11/02 22:15:33
Done.
|
| + base::win::ObjectWatcher watcher_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(AppHostInstaller); |
| +}; |
| + |
| +} // namespace extensions |
| + |
| +#endif // CHROME_BROWSER_EXTENSIONS_APP_HOST_INSTALLER_WIN_H_ |