OLD | NEW |
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 Loading... |
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)), | |
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 Loading... |
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 } |
OLD | NEW |