| OLD | NEW |
| (Empty) |
| 1 // Copyright 2008-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 // TODO(omaha3): Rename the files and class to ondemand_com_decorator.* and | |
| 17 // OnDemandCOMDecorator, respectively. | |
| 18 | |
| 19 #ifndef OMAHA_GOOPDATE_JOB_OBSERVER_H_ | |
| 20 #define OMAHA_GOOPDATE_JOB_OBSERVER_H_ | |
| 21 | |
| 22 #include <windows.h> | |
| 23 #include <atlbase.h> | |
| 24 #include <atlcom.h> | |
| 25 #include "base/scoped_ptr.h" | |
| 26 #include "omaha/client/install_apps.h" | |
| 27 #include "goopdate/omaha3_idl.h" | |
| 28 | |
| 29 namespace omaha { | |
| 30 | |
| 31 class JobObserverCOMDecorator | |
| 32 : public CComObjectRootEx<CComMultiThreadModel>, | |
| 33 public OnDemandObserver, | |
| 34 public IProgressWndEvents { | |
| 35 public: | |
| 36 BEGIN_COM_MAP(JobObserverCOMDecorator) | |
| 37 COM_INTERFACE_ENTRY(IProgressWndEvents) | |
| 38 END_COM_MAP() | |
| 39 | |
| 40 JobObserverCOMDecorator(); | |
| 41 virtual ~JobObserverCOMDecorator(); | |
| 42 void Initialize(IJobObserver* job_observer); | |
| 43 | |
| 44 // OnDemandObserver implementation. | |
| 45 virtual void OnCheckingForUpdate(); | |
| 46 virtual void OnUpdateAvailable(const CString& app_name, | |
| 47 const CString& version_string); | |
| 48 virtual void OnWaitingToDownload(const CString& app_name); | |
| 49 virtual void OnDownloading(const CString& app_name, | |
| 50 int time_remaining_ms, | |
| 51 int pos); | |
| 52 virtual void OnWaitingRetryDownload(const CString& app_name, | |
| 53 time64 next_retry_time); | |
| 54 virtual void OnWaitingToInstall(const CString& app_name, | |
| 55 bool* can_start_install); | |
| 56 virtual void OnInstalling(const CString& app_name); | |
| 57 virtual void OnPause(); | |
| 58 virtual void OnComplete(const ObserverCompletionInfo& observer_info); | |
| 59 virtual void SetEventSink(OnDemandEventsInterface* event_sink); | |
| 60 | |
| 61 void Uninitialize(); | |
| 62 | |
| 63 // IProgressWndEvents. | |
| 64 STDMETHOD(DoPause)(); | |
| 65 STDMETHOD(DoResume)(); | |
| 66 STDMETHOD(DoClose)(); | |
| 67 STDMETHOD(DoRestartBrowsers)(); | |
| 68 STDMETHOD(DoReboot)(); | |
| 69 STDMETHOD(DoLaunchBrowser)(const WCHAR* url); | |
| 70 | |
| 71 private: | |
| 72 OnDemandEventsInterface* on_demand_events() { | |
| 73 return on_demand_events_; | |
| 74 } | |
| 75 | |
| 76 // Since the code is running in an MTA, write access to | |
| 77 // on_demand_events_ must be atomic. | |
| 78 void set_job_events(OnDemandEventsInterface* on_demand_events) { | |
| 79 // InterlockedExchangePointer is broken due to ATL defining a function with | |
| 80 // the same name in the global namespace and hiding the Win32 API. | |
| 81 // InterlockedExchange introduces a full memory barrier. | |
| 82 ::InterlockedExchange( | |
| 83 reinterpret_cast<volatile LONG*>(&on_demand_events_), | |
| 84 reinterpret_cast<LONG>(on_demand_events)); | |
| 85 } | |
| 86 | |
| 87 CComPtr<IJobObserver> job_observer_; | |
| 88 OnDemandEventsInterface* volatile on_demand_events_; | |
| 89 DWORD thread_id_; | |
| 90 DWORD worker_job_thread_id_; | |
| 91 }; | |
| 92 | |
| 93 } // namespace omaha | |
| 94 | |
| 95 #endif // OMAHA_GOOPDATE_JOB_OBSERVER_H_ | |
| OLD | NEW |