diff options
author | tommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-14 02:27:34 +0000 |
---|---|---|
committer | tommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-05-14 02:27:34 +0000 |
commit | 74e9983aad8bb03972a9716de621fd9292cad5b1 (patch) | |
tree | b0fb21f54bf86a2d2ce95db160860b2bc50a11f4 /chrome_frame | |
parent | f35dba2472393299a12e41c6ef3e445a4766215e (diff) | |
download | chromium_src-74e9983aad8bb03972a9716de621fd9292cad5b1.zip chromium_src-74e9983aad8bb03972a9716de621fd9292cad5b1.tar.gz chromium_src-74e9983aad8bb03972a9716de621fd9292cad5b1.tar.bz2 |
Not using std::wstring to store progress status text because mshtml is sensitive to NULL vs L"".
TEST=see bug
BUG=44103
Review URL: http://codereview.chromium.org/2118001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@47232 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame')
-rw-r--r-- | chrome_frame/urlmon_bind_status_callback.cc | 27 | ||||
-rw-r--r-- | chrome_frame/urlmon_bind_status_callback.h | 52 |
2 files changed, 65 insertions, 14 deletions
diff --git a/chrome_frame/urlmon_bind_status_callback.cc b/chrome_frame/urlmon_bind_status_callback.cc index 5730870..0f886a1 100644 --- a/chrome_frame/urlmon_bind_status_callback.cc +++ b/chrome_frame/urlmon_bind_status_callback.cc @@ -204,6 +204,16 @@ void SniffData::DetermineRendererType(bool last_chance) { ///////////////////////////////////////////////////////////////////// +BSCBStorageBind::BSCBStorageBind() : clip_format_(CF_NULL) { +} + +BSCBStorageBind::~BSCBStorageBind() { + for (std::vector<Progress*>::iterator i = saved_progress_.begin(); + i != saved_progress_.end(); i++) { + delete (*i); + } +} + HRESULT BSCBStorageBind::Initialize(IMoniker* moniker, IBindCtx* bind_ctx) { DLOG(INFO) << __FUNCTION__ << me() << StringPrintf(" tid=%i", PlatformThread::CurrentId()); @@ -250,9 +260,8 @@ STDMETHODIMP BSCBStorageBind::OnProgress(ULONG progress, ULONG progress_max, } if (ShouldCacheProgress(status_code)) { - Progress new_progress = { progress, progress_max, status_code, - status_text ? status_text : std::wstring() }; - saved_progress_.push_back(new_progress); + saved_progress_.push_back(new Progress(progress, progress_max, status_code, + status_text)); } else { hr = CallbackImpl::OnProgress(progress, progress_max, status_code, status_text); @@ -347,12 +356,12 @@ HRESULT BSCBStorageBind::MayPlayBack(DWORD flags) { clip_format_ = kMagicClipFormat; } else { if (!saved_progress_.empty()) { - for (std::vector<Progress>::iterator i = saved_progress_.begin(); - i != saved_progress_.end(); i++) { - const wchar_t* status_text = i->status_text_.empty() ? - NULL : i->status_text_.c_str(); - CallbackImpl::OnProgress(i->progress_, i->progress_max_, - i->status_code_, status_text); + for (std::vector<Progress*>::iterator i = saved_progress_.begin(); + i != saved_progress_.end(); i++) { + Progress* p = (*i); + CallbackImpl::OnProgress(p->progress(), p->progress_max(), + p->status_code(), p->status_text()); + delete p; } saved_progress_.clear(); } diff --git a/chrome_frame/urlmon_bind_status_callback.h b/chrome_frame/urlmon_bind_status_callback.h index 484bef3..ef73cb8 100644 --- a/chrome_frame/urlmon_bind_status_callback.h +++ b/chrome_frame/urlmon_bind_status_callback.h @@ -93,7 +93,8 @@ class SniffData { class BSCBStorageBind : public BSCBImpl { public: typedef BSCBImpl CallbackImpl; - BSCBStorageBind() : clip_format_(CF_NULL) {} + BSCBStorageBind(); + ~BSCBStorageBind(); BEGIN_COM_MAP(BSCBStorageBind) COM_INTERFACE_ENTRY(IBindStatusCallback) @@ -117,15 +118,56 @@ END_COM_MAP() protected: SniffData data_sniffer_; - // A structure to cache the progress notifications - struct Progress { + // A structure to cache the progress notifications. + class Progress { + public: + Progress(ULONG progress, ULONG progress_max, ULONG status_code, + const wchar_t* status_text) + : progress_(progress), + progress_max_(progress_max), + status_code_(status_code), + status_text_(NULL) { + if (status_text) { + int len = lstrlenW(status_text) + 1; + status_text_.reset(new wchar_t[len]); + if (status_text_.get()) { + lstrcpyW(status_text_.get(), status_text); + } else { + NOTREACHED(); + } + } + } + + ~Progress() { + } + + ULONG progress() const { + return progress_; + } + + ULONG progress_max() const { + return progress_max_; + } + + ULONG status_code() const { + return status_code_; + } + + const wchar_t* status_text() const { + return status_text_.get(); + } + + protected: ULONG progress_; ULONG progress_max_; ULONG status_code_; - std::wstring status_text_; + // We don't use std::wstring here since we want to be able to play + // progress notifications back exactly as we got them. NULL and L"" are + // not equal. + scoped_ptr<wchar_t> status_text_; }; - std::vector<Progress> saved_progress_; + std::vector<Progress*> saved_progress_; CLIPFORMAT clip_format_; private: |