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

Side by Side Diff: chrome/browser/extensions/app_host_installer_win.cc

Issue 11054006: Make application shortcuts point to app_host.exe, install App Host during app installation. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 2 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 unified diff | Download patch
OLDNEW
(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 #include "chrome/browser/extensions/app_host_installer_win.h"
6
7 #include <windows.h>
benwells 2012/10/03 05:08:43 Some of these includes are in the .h
huangs 2012/10/03 20:09:47 I thought a .cc file should not assume transitive
8 #include "base/bind.h"
9 #include "base/win/object_watcher.h"
10 #include "chrome/installer/launcher_support/chrome_launcher_support.h"
11 #include "content/public/browser/browser_thread.h"
12
13 namespace extensions {
14
15 namespace {
benwells 2012/10/03 05:08:43 Keep the anonymous namespace out of the extensions
huangs 2012/10/03 20:09:47 Done.
16
17 class QuickEnableWatcher : public base::win::ObjectWatcher::Delegate {
18 public:
19 QuickEnableWatcher(bool* running, const base::Closure& on_success,
20 const base::Closure& on_failure)
21 : running_(running),
22 on_success_(on_success),
23 on_failure_(on_failure) {
24 }
25
26 // base::win::ObjectWatcher::Delegate implementation.
27 void OnObjectSignaled(HANDLE object) {
28 DWORD exit_code;
29 ::GetExitCodeProcess(object, &exit_code);
30 if (exit_code == 0)
31 on_success_.Run();
32 else
33 on_failure_.Run();
erikwright (departed) 2012/10/03 15:58:35 Use process_util::GetTerminationStatus instead of
huangs 2012/10/03 20:09:47 Done. I think TerminationStatus is sufficient; we
34 on_success_.Reset();
35 on_failure_.Reset();
36 *running_ = false;
37 }
38
39 private:
40 bool* running_;
41 base::Closure on_success_;
42 base::Closure on_failure_;
43
44 DISALLOW_COPY_AND_ASSIGN(QuickEnableWatcher);
45 };
46 } // namespace
benwells 2012/10/03 05:08:43 Nit: Blank line before end of namespace.
huangs 2012/10/03 20:09:47 Done.
47
48 AppHostInstaller::AppHostInstaller()
49 : running_(false), process_(INVALID_HANDLE_VALUE), delegate_(NULL) {
erikwright (departed) 2012/10/03 15:58:35 process_ and delegate_ are objects whose default c
huangs 2012/10/03 20:09:47 Done.
50 }
51
52 void AppHostInstaller::EnsureAppHostPresentAndCall(
53 const base::Closure& on_success,
54 const base::Closure& on_failure) {
55 using content::BrowserThread;
56 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE));
57 DCHECK(!running_);
benwells 2012/10/03 05:08:43 Is running_ just for this DCHECK?
erikwright (departed) 2012/10/03 15:58:35 It could have been used to allow the AppHostInstal
huangs 2012/10/03 20:09:47 I'm worried about the case where user installs app
huangs 2012/10/03 20:09:47 Done.
58
59 // If installed.
60 if (chrome_launcher_support::IsAppHostPresent()) {
61 on_success.Run();
62 } else {
63 DCHECK(!process_.IsValid());
64 if (FAILED(chrome_launcher_support::LaunchQuickEnableAppHost(&process_))) {
65 on_failure.Run();
66 } else {
67 DCHECK(process_.IsValid());
68 running_ = true;
69 delegate_.reset(
70 new QuickEnableWatcher(&running_, on_success, on_failure));
71 watcher_.StartWatching(process_, delegate_.get());
72 }
73 }
74 }
75
76 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698