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

Side by Side Diff: base/marshal_by_value.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 | « base/logging_unittest.cc ('k') | base/md5.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 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 // This is an implementation of IMarshal that always marshals by value. class T
17 // needs to derive from MarshalByValue, and expose IMarshal through
18 // QueryInterface. class T also needs to expose the IPersistStream-style methods
19 // GetSizeMax(), Save(), and Load().
20
21 #ifndef OMAHA_BASE_MARSHAL_BY_VALUE_H_
22 #define OMAHA_BASE_MARSHAL_BY_VALUE_H_
23
24 #include <atlbase.h>
25 #include "omaha/base/debug.h"
26
27 namespace omaha {
28
29 template <class T>
30 class ATL_NO_VTABLE MarshalByValue : public IMarshal {
31 public:
32 STDMETHOD(GetUnmarshalClass)(REFIID, void*, DWORD, void*, DWORD,
33 CLSID* clsid) {
34 ASSERT1(clsid);
35 *clsid = T::GetObjectCLSID();
36 return S_OK;
37 }
38
39 STDMETHOD(ReleaseMarshalData)(IStream* stream) {
40 UNREFERENCED_PARAMETER(stream);
41 return S_OK;
42 }
43
44 STDMETHOD(DisconnectObject)(DWORD) {
45 return S_OK;
46 }
47
48 STDMETHOD(GetMarshalSizeMax)(REFIID, void*, DWORD, void*, DWORD,
49 DWORD* size) {
50 ASSERT1(size);
51
52 T* persist = static_cast<T*>(this);
53 ULARGE_INTEGER size_max = {0};
54 HRESULT hr = persist->GetSizeMax(&size_max);
55 if (FAILED(hr)) {
56 return hr;
57 }
58
59 *size = size_max.LowPart;
60 return S_OK;
61 }
62
63 STDMETHOD(MarshalInterface)(IStream* stream, REFIID, void*, DWORD, void*,
64 DWORD) {
65 ASSERT1(stream);
66
67 T* persist = static_cast<T*>(this);
68 return persist->Save(stream, FALSE);
69 }
70
71 STDMETHOD(UnmarshalInterface)(IStream* stream, REFIID iid, void** ptr) {
72 ASSERT1(stream);
73 ASSERT1(ptr);
74
75 T* persist = static_cast<T*>(this);
76 HRESULT hr = persist->Load(stream);
77 if (FAILED(hr)) {
78 return hr;
79 }
80
81 return persist->QueryInterface(iid, ptr);
82 }
83 };
84
85 } // namespace omaha
86
87 #endif // OMAHA_BASE_MARSHAL_BY_VALUE_H_
88
OLDNEW
« no previous file with comments | « base/logging_unittest.cc ('k') | base/md5.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698