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

Side by Side Diff: goopdate/model.h

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 | « goopdate/main_unittest.cc ('k') | goopdate/model.cc » ('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 2009-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 // Defines the root of the object model. This is not exposed as a COM object.
17
18 #ifndef OMAHA_GOOPDATE_MODEL_H_
19 #define OMAHA_GOOPDATE_MODEL_H_
20
21 #ifndef _ATL_FREE_THREADED
22 #error Must use _ATL_FREE_THREADED to avoid differences in member offsets.
23 #endif
24
25 #include <windows.h>
26 #include <vector>
27 #include "base/basictypes.h"
28 #include "base/debug.h"
29 #include "base/scoped_ptr.h"
30 #include "base/synchronized.h"
31 #include "omaha/goopdate/app.h"
32 #include "omaha/goopdate/app_bundle.h"
33 #include "omaha/goopdate/app_version.h"
34 #include "omaha/goopdate/current_state.h"
35 #include "omaha/goopdate/package.h"
36 #include "third_party/bar/shared_ptr.h"
37
38 namespace omaha {
39
40 class WorkerModelInterface;
41
42 class Model {
43 public:
44 explicit Model(WorkerModelInterface* worker);
45 virtual ~Model();
46
47 const Lockable& lock() const { return lock_; }
48
49 // Returns true if the model lock is held by the calling thread.
50 bool IsLockedByCaller() const {
51 return ::GetCurrentThreadId() == lock_.GetOwner();
52 }
53
54 // Creates an AppBundle object in the model.
55 shared_ptr<AppBundle> CreateAppBundle(bool is_machine);
56
57 // Removes the AppBundle objects that have no outstanding strong references.
58 void CleanupExpiredAppBundles();
59
60 size_t GetNumberOfAppBundles() const;
61
62 shared_ptr<AppBundle> GetAppBundle(size_t index) const;
63
64 // Initiates an update check for all apps in the bundle.
65 HRESULT CheckForUpdate(AppBundle* app_bundle);
66
67 // Initiates download of files necessary to install all apps in the bundle.
68 HRESULT Download(AppBundle* app_bundle);
69
70 // Initiates Download, if necessary, and install all app in the bundle.
71 HRESULT DownloadAndInstall(AppBundle* app_bundle);
72
73 // Initiates an update of all registered apps and performs periodic tasks
74 // related to all apps. Primarily for use by Omaha's /ua client. Includes
75 // update check, download and install.
76 HRESULT UpdateAllApps(AppBundle* app_bundle);
77
78 HRESULT Stop(AppBundle* app_bundle);
79 HRESULT Pause(AppBundle* app_bundle);
80 HRESULT Resume(AppBundle* app_bundle);
81
82 HRESULT DownloadPackage(Package* package);
83 HRESULT GetPackage(const Package* package, const CString& dir) const;
84
85 bool IsPackageAvailable(const Package* package) const;
86
87 HRESULT PurgeAppLowerVersions(const CString& app_id,
88 const CString& version) const;
89
90 private:
91 typedef weak_ptr<AppBundle> AppBundleWeakPtr;
92
93 // Serializes access to the model objects. Consider replacing with SWMR lock.
94 LLock lock_;
95
96 std::vector<AppBundleWeakPtr> app_bundles_;
97 WorkerModelInterface* worker_;
98
99 DISALLOW_COPY_AND_ASSIGN(Model);
100 };
101
102 } // namespace omaha
103
104 #endif // OMAHA_GOOPDATE_MODEL_H_
OLDNEW
« no previous file with comments | « goopdate/main_unittest.cc ('k') | goopdate/model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698