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

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

Issue 931993002: Make image_decoder a Leaky LazyInstance (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename instance_ to image_decoder_instance_ for mac linker Created 5 years, 9 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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 const storage::CopyOrMoveFileValidator::ResultCallback& callback) 54 const storage::CopyOrMoveFileValidator::ResultCallback& callback)
55 : data_(data.Pass()), callback_(callback) { 55 : data_(data.Pass()), callback_(callback) {
56 DCHECK(data_); 56 DCHECK(data_);
57 } 57 }
58 58
59 const std::string& data() { 59 const std::string& data() {
60 return *data_; 60 return *data_;
61 } 61 }
62 62
63 // ImageDecoder::Delegate methods. 63 // ImageDecoder::Delegate methods.
64 void OnImageDecoded(const ImageDecoder* /*decoder*/, 64 void OnImageDecoded(const SkBitmap& /*decoded_image*/) override {
65 const SkBitmap& /*decoded_image*/) override {
66 callback_.Run(base::File::FILE_OK); 65 callback_.Run(base::File::FILE_OK);
67 delete this; 66 delete this;
68 } 67 }
69 68
70 void OnDecodeImageFailed(const ImageDecoder* /*decoder*/) override { 69 void OnDecodeImageFailed() override {
71 callback_.Run(base::File::FILE_ERROR_SECURITY); 70 callback_.Run(base::File::FILE_ERROR_SECURITY);
72 delete this; 71 delete this;
73 } 72 }
74 73
75 private: 74 private:
76 scoped_ptr<std::string> data_; 75 scoped_ptr<std::string> data_;
77 storage::CopyOrMoveFileValidator::ResultCallback callback_; 76 storage::CopyOrMoveFileValidator::ResultCallback callback_;
78 77
79 DISALLOW_COPY_AND_ASSIGN(ImageDecoderDelegateAdapter); 78 DISALLOW_COPY_AND_ASSIGN(ImageDecoderDelegateAdapter);
80 }; 79 };
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 void SupportedImageTypeValidator::OnFileOpen(scoped_ptr<std::string> data) { 119 void SupportedImageTypeValidator::OnFileOpen(scoped_ptr<std::string> data) {
121 DCHECK_CURRENTLY_ON(BrowserThread::IO); 120 DCHECK_CURRENTLY_ON(BrowserThread::IO);
122 if (!data.get()) { 121 if (!data.get()) {
123 callback_.Run(base::File::FILE_ERROR_SECURITY); 122 callback_.Run(base::File::FILE_ERROR_SECURITY);
124 return; 123 return;
125 } 124 }
126 125
127 // |adapter| will delete itself after a completion message is received. 126 // |adapter| will delete itself after a completion message is received.
128 ImageDecoderDelegateAdapter* adapter = 127 ImageDecoderDelegateAdapter* adapter =
129 new ImageDecoderDelegateAdapter(data.Pass(), callback_); 128 new ImageDecoderDelegateAdapter(data.Pass(), callback_);
130 decoder_ = new ImageDecoder(adapter, adapter->data(), 129 ImageDecoder::GetInstance()->Start(
131 ImageDecoder::DEFAULT_CODEC); 130 adapter, adapter->data(), ImageDecoder::DEFAULT_CODEC,
132 decoder_->Start(content::BrowserThread::GetMessageLoopProxyForThread( 131 content::BrowserThread::GetMessageLoopProxyForThread(
133 BrowserThread::IO)); 132 BrowserThread::IO));
134 } 133 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698