OLD | NEW |
| (Empty) |
1 // Copyright 2010 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/goopdate/app_bundle_state_ready.h" | |
17 #include "omaha/base/debug.h" | |
18 #include "omaha/base/logging.h" | |
19 #include "omaha/goopdate/app_bundle_state_busy.h" | |
20 #include "omaha/goopdate/model.h" | |
21 | |
22 namespace omaha { | |
23 | |
24 namespace fsm { | |
25 | |
26 HRESULT AppBundleStateReady::Download(AppBundle* app_bundle) { | |
27 CORE_LOG(L3, (_T("[AppBundleStateReady::Download][0x%p]"), app_bundle)); | |
28 ASSERT1(app_bundle); | |
29 ASSERT1(app_bundle->model()->IsLockedByCaller()); | |
30 ASSERT1(!IsPendingNonBlockingCall(app_bundle)); | |
31 | |
32 HRESULT hr = app_bundle->model()->Download(app_bundle); | |
33 if (FAILED(hr)) { | |
34 CORE_LOG(LE, (_T("[Download failed][0x%08x][0x%p]"), hr, app_bundle)); | |
35 return hr; | |
36 } | |
37 | |
38 ChangeState(app_bundle, new AppBundleStateBusy); | |
39 return S_OK; | |
40 } | |
41 | |
42 HRESULT AppBundleStateReady::Install(AppBundle* app_bundle) { | |
43 CORE_LOG(L3, (_T("[AppBundleStateReady::Install][0x%p]"), app_bundle)); | |
44 ASSERT1(app_bundle); | |
45 ASSERT1(app_bundle->model()->IsLockedByCaller()); | |
46 ASSERT1(!IsPendingNonBlockingCall(app_bundle)); | |
47 | |
48 HRESULT hr = app_bundle->model()->DownloadAndInstall(app_bundle); | |
49 if (FAILED(hr)) { | |
50 CORE_LOG(LE, (_T("[Install failed][0x%08x][0x%p]"), hr, app_bundle)); | |
51 return hr; | |
52 } | |
53 | |
54 ChangeState(app_bundle, new AppBundleStateBusy); | |
55 return S_OK; | |
56 } | |
57 | |
58 // Remains in this state since there is nothing to pause. | |
59 HRESULT AppBundleStateReady::Pause(AppBundle* app_bundle) { | |
60 CORE_LOG(L3, (_T("[AppBundleStateReady::Pause][0x%p]"), app_bundle)); | |
61 UNREFERENCED_PARAMETER(app_bundle); | |
62 return S_OK; | |
63 } | |
64 | |
65 // Remains in this state since the bundle is not paused. This might occur if | |
66 // Pause() was called while in this state. | |
67 HRESULT AppBundleStateReady::Resume(AppBundle* app_bundle) { | |
68 CORE_LOG(L3, (_T("[AppBundleStateReady::Resume][0x%p]"), app_bundle)); | |
69 UNREFERENCED_PARAMETER(app_bundle); | |
70 return S_OK; | |
71 } | |
72 | |
73 HRESULT AppBundleStateReady::DownloadPackage(AppBundle* app_bundle, | |
74 const CString& app_id, | |
75 const CString& package_name) { | |
76 CORE_LOG(L3, (_T("[AppBundleStateReady::DownloadPackage][0x%p]"), | |
77 app_bundle)); | |
78 | |
79 // TODO(omaha): There may need to be some check here that the app is | |
80 // downloaded or installed. | |
81 | |
82 return DoDownloadPackage(app_bundle, app_id, package_name); | |
83 } | |
84 | |
85 } // namespace fsm | |
86 | |
87 } // namespace omaha | |
OLD | NEW |