| 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 #ifndef OMAHA_GOOPDATE_COCREATE_ASYNC_H_ | |
| 17 #define OMAHA_GOOPDATE_COCREATE_ASYNC_H_ | |
| 18 | |
| 19 #include <atlbase.h> | |
| 20 #include <oaidl.h> | |
| 21 #include <oleauto.h> | |
| 22 #include "goopdate/omaha3_idl.h" | |
| 23 #include "omaha/base/atlregmapex.h" | |
| 24 #include "omaha/base/synchronized.h" | |
| 25 #include "omaha/common/const_goopdate.h" | |
| 26 #include "omaha/common/goopdate_utils.h" | |
| 27 #include "omaha/goopdate/com_proxy.h" | |
| 28 #include "omaha/goopdate/non_localized_resource.h" | |
| 29 | |
| 30 namespace omaha { | |
| 31 | |
| 32 #pragma warning(push) | |
| 33 // Construction of local static object is not thread-safe | |
| 34 #pragma warning(disable:4640) | |
| 35 | |
| 36 class ATL_NO_VTABLE CoCreateAsync | |
| 37 : public CComObjectRootEx<CComObjectThreadModel>, | |
| 38 public CComCoClass<CoCreateAsync, &__uuidof(CoCreateAsyncClass)>, | |
| 39 public ICoCreateAsync, | |
| 40 public StdMarshalInfo { | |
| 41 public: | |
| 42 CoCreateAsync(); | |
| 43 | |
| 44 STDMETHOD(createOmahaMachineServerAsync)(BSTR origin_url, | |
| 45 BOOL create_elevated, | |
| 46 ICoCreateAsyncStatus** status); | |
| 47 | |
| 48 DECLARE_NOT_AGGREGATABLE(CoCreateAsync); | |
| 49 DECLARE_REGISTRY_RESOURCEID_EX(IDR_LOCAL_SERVER_RGS) | |
| 50 | |
| 51 BEGIN_REGISTRY_MAP() | |
| 52 REGMAP_ENTRY(_T("HKROOT"), goopdate_utils::GetHKRoot()) | |
| 53 REGMAP_MODULE2(_T("MODULE"), kOmahaBrokerFileName) | |
| 54 REGMAP_ENTRY(_T("VERSION"), _T("1.0")) | |
| 55 REGMAP_ENTRY(_T("PROGID"), kProgIDCoCreateAsync) | |
| 56 REGMAP_ENTRY(_T("DESCRIPTION"), _T("CoCreateAsync")) | |
| 57 REGMAP_UUID(_T("CLSID"), GetObjectCLSID()) | |
| 58 END_REGISTRY_MAP() | |
| 59 | |
| 60 BEGIN_COM_MAP(CoCreateAsync) | |
| 61 COM_INTERFACE_ENTRY(ICoCreateAsync) | |
| 62 COM_INTERFACE_ENTRY(IStdMarshalInfo) | |
| 63 END_COM_MAP() | |
| 64 | |
| 65 protected: | |
| 66 virtual ~CoCreateAsync() {} | |
| 67 | |
| 68 private: | |
| 69 DISALLOW_COPY_AND_ASSIGN(CoCreateAsync); | |
| 70 }; | |
| 71 | |
| 72 class ATL_NO_VTABLE CoCreateAsyncStatus | |
| 73 : public CComObjectRootEx<CComObjectThreadModel>, | |
| 74 public IDispatchImpl<ICoCreateAsyncStatus, | |
| 75 &__uuidof(ICoCreateAsyncStatus), | |
| 76 &CAtlModule::m_libid, | |
| 77 kMajorTypeLibVersion, | |
| 78 kMinorTypeLibVersion> { | |
| 79 public: | |
| 80 CoCreateAsyncStatus(); | |
| 81 HRESULT CreateOmahaMachineServerAsync(BSTR origin_url, BOOL create_elevated); | |
| 82 | |
| 83 // ICoCreateAsyncStatus. | |
| 84 STDMETHOD(get_isDone)(VARIANT_BOOL* is_done); | |
| 85 STDMETHOD(get_completionHResult)(LONG* hr); | |
| 86 STDMETHOD(get_createdInstance)(IDispatch** instance); | |
| 87 | |
| 88 BEGIN_COM_MAP(CoCreateAsyncStatus) | |
| 89 COM_INTERFACE_ENTRY(ICoCreateAsyncStatus) | |
| 90 COM_INTERFACE_ENTRY(IDispatch) | |
| 91 END_COM_MAP() | |
| 92 | |
| 93 protected: | |
| 94 virtual ~CoCreateAsyncStatus() {} | |
| 95 | |
| 96 private: | |
| 97 void CreateOmahaMachineServer(const CString origin_url, BOOL create_elevated); | |
| 98 void SetCreateInstanceResults(const HRESULT& hr, | |
| 99 const CComPtr<IDispatch>& ptr); | |
| 100 | |
| 101 Gate thread_started_gate_; | |
| 102 | |
| 103 bool is_done_; | |
| 104 HRESULT hr_; | |
| 105 CComPtr<IDispatch> ptr_; | |
| 106 | |
| 107 DISALLOW_COPY_AND_ASSIGN(CoCreateAsyncStatus); | |
| 108 }; | |
| 109 | |
| 110 #pragma warning(pop) | |
| 111 | |
| 112 } // namespace omaha | |
| 113 | |
| 114 #endif // OMAHA_GOOPDATE_COCREATE_ASYNC_H_ | |
| OLD | NEW |