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

Side by Side Diff: chrome/browser/media_galleries/fileapi/supported_image_type_validator.cc

Issue 1067593005: Fix race conditions in ImageDecoder. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: do not use MessageLoopProxy Created 5 years, 8 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include "chrome/browser/media_galleries/fileapi/supported_image_type_validator. h" 5 #include "chrome/browser/media_galleries/fileapi/supported_image_type_validator. h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/files/file.h" 9 #include "base/files/file.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 } 45 }
46 46
47 return result.Pass(); 47 return result.Pass();
48 } 48 }
49 49
50 class ImageDecoderDelegateAdapter : public ImageDecoder::ImageRequest { 50 class ImageDecoderDelegateAdapter : public ImageDecoder::ImageRequest {
51 public: 51 public:
52 ImageDecoderDelegateAdapter( 52 ImageDecoderDelegateAdapter(
53 scoped_ptr<std::string> data, 53 scoped_ptr<std::string> data,
54 const storage::CopyOrMoveFileValidator::ResultCallback& callback) 54 const storage::CopyOrMoveFileValidator::ResultCallback& callback)
55 : ImageRequest(content::BrowserThread::GetMessageLoopProxyForThread( 55 : data_(data.Pass()),
56 BrowserThread::IO)),
Theresa 2015/04/20 22:35:26 I'm not familiar enough with this class to know wh
Lei Zhang 2015/04/21 00:44:00 The only place that calls the ImageDecoderDelegate
57 data_(data.Pass()),
58 callback_(callback) { 56 callback_(callback) {
59 DCHECK(data_); 57 DCHECK(data_);
60 } 58 }
61 59
62 const std::string& data() { 60 const std::string& data() {
63 return *data_; 61 return *data_;
64 } 62 }
65 63
66 // ImageDecoder::ImageRequest methods. 64 // ImageDecoder::ImageRequest methods.
67 void OnImageDecoded(const SkBitmap& /*decoded_image*/) override { 65 void OnImageDecoded(const SkBitmap& /*decoded_image*/) override {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 if (!data.get()) { 122 if (!data.get()) {
125 callback_.Run(base::File::FILE_ERROR_SECURITY); 123 callback_.Run(base::File::FILE_ERROR_SECURITY);
126 return; 124 return;
127 } 125 }
128 126
129 // |adapter| will delete itself after a completion message is received. 127 // |adapter| will delete itself after a completion message is received.
130 ImageDecoderDelegateAdapter* adapter = 128 ImageDecoderDelegateAdapter* adapter =
131 new ImageDecoderDelegateAdapter(data.Pass(), callback_); 129 new ImageDecoderDelegateAdapter(data.Pass(), callback_);
132 ImageDecoder::Start(adapter, adapter->data()); 130 ImageDecoder::Start(adapter, adapter->data());
133 } 131 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698