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

Side by Side Diff: client/shutdown_events.cc

Issue 624713003: Keep only base/extractor.[cc|h]. (Closed) Base URL: https://chromium.googlesource.com/external/omaha.git@master
Patch Set: Created 6 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
« no previous file with comments | « client/shutdown_events.h ('k') | client/ua.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2011 Google Inc.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 // ========================================================================
15
16 #include "omaha/client/shutdown_events.h"
17 #include <atlsafe.h>
18 #include "base/scoped_ptr.h"
19 #include "omaha/base/debug.h"
20 #include "omaha/base/error.h"
21 #include "omaha/base/logging.h"
22 #include "omaha/base/reactor.h"
23 #include "omaha/base/shutdown_handler.h"
24 #include "omaha/base/synchronized.h"
25 #include "omaha/client/bundle_installer.h"
26
27 namespace omaha {
28
29 ShutdownEvents::ShutdownEvents(BundleInstaller* installer)
30 : installer_(installer) {
31 ASSERT1(installer);
32 }
33
34 ShutdownEvents::~ShutdownEvents() {
35 CORE_LOG(L2, (_T("[ShutdownEvents::~ShutdownEvents]")));
36 __mutexScope(lock_);
37
38 CORE_LOG(L2, (_T("[Destroying shutdown handler]")));
39 shutdown_handler_.reset();
40 reactor_.reset();
41 }
42
43 HRESULT ShutdownEvents::InitializeShutdownHandler(bool is_machine) {
44 CORE_LOG(L3, (_T("[InitializeShutdownHandler]")));
45
46 reactor_.reset(new Reactor);
47 shutdown_handler_.reset(new ShutdownHandler);
48 return shutdown_handler_->Initialize(reactor_.get(), this, is_machine);
49 }
50
51 // Shutdown() is called from a thread in the OS threadpool. The PostMessage
52 // marshals the call over to the UI thread, which is where DoClose needs to be
53 // (and is) called from.
54 HRESULT ShutdownEvents::Shutdown() {
55 CORE_LOG(L2, (_T("[Shutdown]")));
56
57 __mutexScope(lock_);
58
59 CORE_LOG(L2, (_T("[Shutdown][IsWindow: %d]"), installer_->IsWindow()));
60 if (installer_->IsWindow()) {
61 installer_->PostMessage(WM_CLOSE, 0, 0);
62 }
63
64 return S_OK;
65 }
66
67 HRESULT ShutdownEvents::CreateShutdownHandler(
68 bool is_machine,
69 BundleInstaller* installer,
70 ShutdownCallback** shutdown_callback) {
71 ASSERT1(installer);
72 ASSERT1(shutdown_callback);
73 ASSERT1(!*shutdown_callback);
74
75 scoped_ptr<ShutdownEvents> shutdown_events(new ShutdownEvents(installer));
76 HRESULT hr = shutdown_events->InitializeShutdownHandler(is_machine);
77 if (FAILED(hr)) {
78 CORE_LOG(LE, (_T("[InitializeShutDownHandler failed][0x%08x]"), hr));
79 return hr;
80 }
81
82 *shutdown_callback = shutdown_events.release();
83 return S_OK;
84 }
85
86 } // namespace omaha
OLDNEW
« no previous file with comments | « client/shutdown_events.h ('k') | client/ua.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698