| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_BROWSER_UI_WEBUI_CHROMEOS_IMAGE_SOURCE_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_CHROMEOS_IMAGE_SOURCE_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_IMAGE_SOURCE_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_CHROMEOS_IMAGE_SOURCE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 public: | 31 public: |
| 32 ImageSource(); | 32 ImageSource(); |
| 33 ~ImageSource() override; | 33 ~ImageSource() override; |
| 34 | 34 |
| 35 // content::URLDataSource implementation. | 35 // content::URLDataSource implementation. |
| 36 std::string GetSource() const override; | 36 std::string GetSource() const override; |
| 37 void StartDataRequest( | 37 void StartDataRequest( |
| 38 const std::string& path, | 38 const std::string& path, |
| 39 int render_process_id, | 39 int render_process_id, |
| 40 int render_frame_id, | 40 int render_frame_id, |
| 41 const content::URLDataSource::GotDataCallback& callback) override; | 41 const content::URLDataSource::GotDataCallback& got_data_callback) |
| 42 override; |
| 43 |
| 42 std::string GetMimeType(const std::string& path) const override; | 44 std::string GetMimeType(const std::string& path) const override; |
| 43 | 45 |
| 44 private: | 46 private: |
| 45 void StartOnFileThread( | 47 // Callback after attempting to start loading the image. |
| 46 const std::string& path, | 48 void LoadImageAttempted( |
| 47 const content::URLDataSource::GotDataCallback& callback); | 49 const content::URLDataSource::GotDataCallback& got_data_callback, |
| 50 bool load_started); |
| 48 | 51 |
| 49 // Callback for user_manager::UserImageLoader. | 52 // Callback for user_manager::UserImageLoader. |
| 50 void ImageLoaded( | 53 void ImageLoaded( |
| 51 const content::URLDataSource::GotDataCallback& callback, | 54 const content::URLDataSource::GotDataCallback& got_data_callback, |
| 52 const user_manager::UserImage& user_image) const; | 55 const user_manager::UserImage& user_image) const; |
| 53 | 56 |
| 54 // Checks whether we have allowed the image to be loaded. | 57 // Checks whether we have allowed the image to be loaded. |
| 55 bool IsWhitelisted(const std::string& path) const; | 58 bool IsWhitelisted(const std::string& path) const; |
| 56 | 59 |
| 57 // The background task runner on which file I/O and image decoding are done. | 60 // The background task runner on which file I/O and image decoding are done. |
| 58 scoped_refptr<base::SequencedTaskRunner> task_runner_; | 61 scoped_refptr<base::SequencedTaskRunner> task_runner_; |
| 59 | 62 |
| 60 scoped_refptr<UserImageLoader> image_loader_; | 63 scoped_refptr<UserImageLoader> image_loader_; |
| 61 | 64 |
| 62 base::WeakPtrFactory<ImageSource> weak_factory_; | 65 base::WeakPtrFactory<ImageSource> weak_factory_; |
| 63 | 66 |
| 64 DISALLOW_COPY_AND_ASSIGN(ImageSource); | 67 DISALLOW_COPY_AND_ASSIGN(ImageSource); |
| 65 }; | 68 }; |
| 66 | 69 |
| 67 } // namespace chromeos | 70 } // namespace chromeos |
| 68 | 71 |
| 69 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_IMAGE_SOURCE_H_ | 72 #endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_IMAGE_SOURCE_H_ |
| OLD | NEW |