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

Side by Side Diff: common/controlled_object.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 | « common/const_group_policy.h ('k') | common/event_logger.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 2005-2009 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 // This class is similar to CComContainedObject. The primary difference is with
17 // respect to QueryInterface, which this class handles itself, as opposed to
18 // CComContainedObject that delegates that to the outer unknown.
19
20 #ifndef OMAHA_COMMON_CONTROLLED_OBJECT_H_
21 #define OMAHA_COMMON_CONTROLLED_OBJECT_H_
22
23 #include <atlcom.h>
24 #include "base/scoped_ptr.h"
25 #include "omaha/base/debug.h"
26 #include "omaha/base/logging.h"
27 #include "omaha/base/scoped_ptr_address.h"
28
29 namespace omaha {
30
31 template <class Base>
32 class ControlledObject : public CComContainedObject<Base> {
33 public:
34 typedef CComContainedObject<Base> BaseClass;
35 typedef ControlledObject<Base> ControlledObj;
36
37 // The base class CComContainedObject stores pv, and delegates to this
38 // controlling unknown subsequent calls to the lifetime methods
39 // AddRef/Release.
40 explicit ControlledObject(void* pv) : BaseClass(pv) {}
41 virtual ~ControlledObject() {}
42
43 STDMETHOD(QueryInterface)(REFIID iid, void** ppv) throw() {
44 return _InternalQueryInterface(iid, ppv);
45 }
46
47 // TODO(omaha): ASSERT on controlling_unknown. The unit tests need to be
48 // fixed for this.
49 static HRESULT WINAPI CreateInstance(IUnknown* controlling_unknown,
50 ControlledObj** pp) throw() {
51 ASSERT1(pp);
52 if (!controlling_unknown) {
53 CORE_LOG(LW, (_T("[CreateInstance - controlling_unknown is NULL]")));
54 }
55
56 *pp = NULL;
57 scoped_ptr<ControlledObj> p(new ControlledObj(controlling_unknown));
58 if (!p.get()) {
59 return E_OUTOFMEMORY;
60 }
61
62 HRESULT hr = p->FinalConstruct();
63 if (FAILED(hr)) {
64 return hr;
65 }
66
67 *pp = p.release();
68 return S_OK;
69 }
70
71 template <class Q>
72 HRESULT STDMETHODCALLTYPE QueryInterface(Q** pp) throw() {
73 return QueryInterface(__uuidof(Q), reinterpret_cast<void**>(pp));
74 }
75 };
76
77 } // namespace omaha
78
79 #endif // OMAHA_COMMON_CONTROLLED_OBJECT_H_
80
OLDNEW
« no previous file with comments | « common/const_group_policy.h ('k') | common/event_logger.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698