Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_APP_HOST_INSTALLER_WIN_H_ | |
| 6 #define CHROME_BROWSER_EXTENSIONS_APP_HOST_INSTALLER_WIN_H_ | |
| 7 | |
| 8 #include "base/basictypes.h" | |
| 9 #include "base/callback_forward.h" | |
| 10 #include "base/win/object_watcher.h" | |
| 11 #include "chrome/browser/extensions/app_host_installer_win.h" | |
| 12 #include "content/public/browser/browser_thread.h" | |
| 13 | |
| 14 namespace extensions { | |
| 15 | |
| 16 class Extension; | |
| 17 | |
| 18 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).
| |
| 19 | |
| 20 // Called on the original calling thread after InstallAppHostIfNecessary() | |
| 21 // is complete. A boolean flag is passed, which is false iff the installation | |
| 22 // was required but failed. | |
| 23 typedef base::Callback<void(bool)> OnAppHostInstallationCompleteCallback; | |
| 24 | |
| 25 // Determines if the App Host is installed and, if not, installs it. | |
| 26 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
| |
| 27 public: | |
| 28 // Asynchronously checks the system state and installs the App Host if not | |
| 29 // present. |completion_callback| will be notified on the caller's thread | |
| 30 // when the installation process completes, and is passed a boolean to | |
| 31 // indicate success or failure of installation. | |
| 32 // No timeout is used - thus |completion_callback| may be held for an | |
| 33 // arbitrarily long time, including past browser shutdown. | |
| 34 static void EnsureAppHostInstalled( | |
| 35 const OnAppHostInstallationCompleteCallback& completion_callback); | |
| 36 | |
| 37 private: | |
| 38 // Constructs an AppHostInstaller, which will call |completion_callback| | |
| 39 // on the specified thread upon installation completion. | |
| 40 AppHostInstaller( | |
| 41 const OnAppHostInstallationCompleteCallback& completion_callback, | |
| 42 BrowserThread::ID caller_thread_id); | |
| 43 | |
| 44 ~AppHostInstaller(); | |
| 45 | |
| 46 // Checks the system state on the FILE thread. Will call | |
| 47 // InstallAppHostOnFileThread() if App Host is not installed. | |
| 48 void EnsureAppHostInstalledInternal(); | |
| 49 | |
| 50 // Runs on the FILE thread. Installs App Host by asynchronously triggering | |
| 51 // App Host installation. Will call FinishOnCallerThread() upon completion | |
| 52 // (successful or otherwise). | |
| 53 void InstallAppHostOnFileThread(); | |
| 54 | |
| 55 // Passes |success| to |completion_callback| on the original caller thread. | |
| 56 // Deletes the AppHostInstaller. | |
| 57 void FinishOnCallerThread(bool success); | |
| 58 | |
| 59 OnAppHostInstallationCompleteCallback completion_callback_; | |
| 60 BrowserThread::ID caller_thread_id_; | |
| 61 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.
| |
| 62 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.
| |
| 63 base::win::ObjectWatcher watcher_; | |
| 64 | |
| 65 DISALLOW_COPY_AND_ASSIGN(AppHostInstaller); | |
| 66 }; | |
| 67 | |
| 68 } // namespace extensions | |
| 69 | |
| 70 #endif // CHROME_BROWSER_EXTENSIONS_APP_HOST_INSTALLER_WIN_H_ | |
| OLD | NEW |