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_IMPL_WIN_H_ | |
| 6 #define CHROME_BROWSER_EXTENSIONS_APP_HOST_INSTALLER_IMPL_WIN_H_ | |
| 7 | |
| 8 #include "base/basictypes.h" | |
| 9 #include "base/callback_forward.h" | |
| 10 #include "base/win/object_watcher.h" | |
| 11 #include "content/public/browser/browser_thread.h" | |
| 12 | |
| 13 namespace extensions { | |
| 14 | |
| 15 class Extension; | |
| 16 | |
| 17 namespace app_host_installer { | |
| 18 | |
| 19 using content::BrowserThread; | |
| 20 | |
| 21 // Determines if the App Host is installed and, if not, installs it. | |
| 22 class AppHostInstallerImpl { | |
| 23 public: | |
| 24 // Asynchronously checks the system state and installs the App Host if not | |
| 25 // present. |completion_callback| will be notified on the caller's thread | |
|
grt (UTC plus 2)
2012/10/24 15:59:18
what does the bool arg for the completion_callback
huangs
2012/10/24 18:52:45
Done.
| |
| 26 // when the installation process completes. No timeout is used - thus | |
| 27 // |completion_callback| may be held for an arbitrarily long time, | |
| 28 // including past browser shutdown. | |
| 29 static void EnsureAppHostInstalled( | |
| 30 const base::Callback<void(bool)>& completion_callback); | |
| 31 | |
| 32 private: | |
| 33 // Constructs an AppHostInstallerImpl, which will call |completion_callback| | |
| 34 // on the specified thread upon installation completion. | |
| 35 AppHostInstallerImpl(const base::Callback<void(bool)>& completion_callback, | |
| 36 BrowserThread::ID caller_thread_id); | |
| 37 | |
| 38 ~AppHostInstallerImpl(); | |
| 39 | |
| 40 // Checks the system state on the FILE thread. Will trigger InstallAppHost() | |
| 41 // if App Host is not installed. | |
| 42 void EnsureAppHostInstalledInternal(); | |
| 43 | |
| 44 // Runs on the FILE thread. Installs App Host by asynchronously triggering | |
| 45 // App Host installation. Will call "Finish" upon completion (successful | |
| 46 // or otherwise). | |
| 47 void InstallAppHost(); | |
|
grt (UTC plus 2)
2012/10/24 15:59:18
nit: There's a convention to suffix funcs that mus
huangs
2012/10/24 18:52:45
Done. Changing my code only though.
| |
| 48 | |
| 49 // Passes |success| to |completion_callback| on the original caller thread. | |
| 50 // Deletes the AppHostInstallerImpl. | |
| 51 void Finish(bool success); | |
| 52 | |
| 53 base::Callback<void(bool)> completion_callback_; | |
| 54 BrowserThread::ID caller_thread_id_; | |
| 55 base::win::ScopedHandle process_; | |
| 56 scoped_ptr<base::win::ObjectWatcher::Delegate> delegate_; | |
| 57 base::win::ObjectWatcher watcher_; | |
| 58 | |
| 59 DISALLOW_COPY_AND_ASSIGN(AppHostInstallerImpl); | |
| 60 }; | |
| 61 | |
| 62 } // namespace app_host_installer | |
| 63 | |
| 64 } // namespace extensions | |
| 65 | |
| 66 #endif // CHROME_BROWSER_EXTENSIONS_APP_HOST_INSTALLER_IMPL_WIN_H_ | |
| OLD | NEW |