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

Side by Side Diff: chrome_frame/urlmon_bind_status_callback.h

Issue 2087004: Merge 47232 - Not using std::wstring to store progress status text because ms... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/375/src/
Patch Set: Created 10 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome_frame/urlmon_bind_status_callback.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_FRAME_URLMON_BIND_STATUS_CALLBACK_H_ 5 #ifndef CHROME_FRAME_URLMON_BIND_STATUS_CALLBACK_H_
6 #define CHROME_FRAME_URLMON_BIND_STATUS_CALLBACK_H_ 6 #define CHROME_FRAME_URLMON_BIND_STATUS_CALLBACK_H_
7 7
8 #include <atlbase.h> 8 #include <atlbase.h>
9 #include <atlcom.h> 9 #include <atlcom.h>
10 10
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 bool eof_; 86 bool eof_;
87 87
88 private: 88 private:
89 DISALLOW_COPY_AND_ASSIGN(SniffData); 89 DISALLOW_COPY_AND_ASSIGN(SniffData);
90 }; 90 };
91 91
92 // A wrapper for bind status callback in IMoniker::BindToStorage 92 // A wrapper for bind status callback in IMoniker::BindToStorage
93 class BSCBStorageBind : public BSCBImpl { 93 class BSCBStorageBind : public BSCBImpl {
94 public: 94 public:
95 typedef BSCBImpl CallbackImpl; 95 typedef BSCBImpl CallbackImpl;
96 BSCBStorageBind() : clip_format_(CF_NULL) {} 96 BSCBStorageBind();
97 ~BSCBStorageBind();
97 98
98 BEGIN_COM_MAP(BSCBStorageBind) 99 BEGIN_COM_MAP(BSCBStorageBind)
99 COM_INTERFACE_ENTRY(IBindStatusCallback) 100 COM_INTERFACE_ENTRY(IBindStatusCallback)
100 COM_INTERFACE_ENTRY_CHAIN(CallbackImpl) 101 COM_INTERFACE_ENTRY_CHAIN(CallbackImpl)
101 END_COM_MAP() 102 END_COM_MAP()
102 103
103 HRESULT Initialize(IMoniker* moniker, IBindCtx* bind_ctx); 104 HRESULT Initialize(IMoniker* moniker, IBindCtx* bind_ctx);
104 HRESULT MayPlayBack(DWORD flags); 105 HRESULT MayPlayBack(DWORD flags);
105 106
106 // IBindStatusCallback 107 // IBindStatusCallback
107 STDMETHOD(OnProgress)(ULONG progress, ULONG progress_max, ULONG status_code, 108 STDMETHOD(OnProgress)(ULONG progress, ULONG progress_max, ULONG status_code,
108 LPCWSTR status_text); 109 LPCWSTR status_text);
109 STDMETHOD(OnDataAvailable)(DWORD flags, DWORD size, FORMATETC* format_etc, 110 STDMETHOD(OnDataAvailable)(DWORD flags, DWORD size, FORMATETC* format_etc,
110 STGMEDIUM* stgmed); 111 STGMEDIUM* stgmed);
111 STDMETHOD(OnStopBinding)(HRESULT hresult, LPCWSTR error); 112 STDMETHOD(OnStopBinding)(HRESULT hresult, LPCWSTR error);
112 113
113 protected: 114 protected:
114 // is it a good time to start caching progress notifications 115 // is it a good time to start caching progress notifications
115 bool ShouldCacheProgress(ULONG status_code) const; 116 bool ShouldCacheProgress(ULONG status_code) const;
116 117
117 protected: 118 protected:
118 SniffData data_sniffer_; 119 SniffData data_sniffer_;
119 120
120 // A structure to cache the progress notifications 121 // A structure to cache the progress notifications.
121 struct Progress { 122 class Progress {
123 public:
124 Progress(ULONG progress, ULONG progress_max, ULONG status_code,
125 const wchar_t* status_text)
126 : progress_(progress),
127 progress_max_(progress_max),
128 status_code_(status_code),
129 status_text_(NULL) {
130 if (status_text) {
131 int len = lstrlenW(status_text) + 1;
132 status_text_.reset(new wchar_t[len]);
133 if (status_text_.get()) {
134 lstrcpyW(status_text_.get(), status_text);
135 } else {
136 NOTREACHED();
137 }
138 }
139 }
140
141 ~Progress() {
142 }
143
144 ULONG progress() const {
145 return progress_;
146 }
147
148 ULONG progress_max() const {
149 return progress_max_;
150 }
151
152 ULONG status_code() const {
153 return status_code_;
154 }
155
156 const wchar_t* status_text() const {
157 return status_text_.get();
158 }
159
160 protected:
122 ULONG progress_; 161 ULONG progress_;
123 ULONG progress_max_; 162 ULONG progress_max_;
124 ULONG status_code_; 163 ULONG status_code_;
125 std::wstring status_text_; 164 // We don't use std::wstring here since we want to be able to play
165 // progress notifications back exactly as we got them. NULL and L"" are
166 // not equal.
167 scoped_ptr<wchar_t> status_text_;
126 }; 168 };
127 169
128 std::vector<Progress> saved_progress_; 170 std::vector<Progress*> saved_progress_;
129 CLIPFORMAT clip_format_; 171 CLIPFORMAT clip_format_;
130 172
131 private: 173 private:
132 DISALLOW_COPY_AND_ASSIGN(BSCBStorageBind); 174 DISALLOW_COPY_AND_ASSIGN(BSCBStorageBind);
133 }; 175 };
134 176
135 #endif // CHROME_FRAME_URLMON_BIND_STATUS_CALLBACK_H_ 177 #endif // CHROME_FRAME_URLMON_BIND_STATUS_CALLBACK_H_
OLDNEW
« no previous file with comments | « no previous file | chrome_frame/urlmon_bind_status_callback.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698