| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/extensions/image_loading_tracker.h" | 5 #include "chrome/browser/extensions/image_loading_tracker.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "chrome/common/extensions/extension.h" | 8 #include "chrome/common/extensions/extension.h" |
| 9 #include "chrome/common/extensions/extension_resource.h" | 9 #include "chrome/common/extensions/extension_resource.h" |
| 10 #include "content/browser/browser_thread.h" | 10 #include "content/browser/browser_thread.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 void LoadImage(const ExtensionResource& resource, | 40 void LoadImage(const ExtensionResource& resource, |
| 41 const gfx::Size& max_size, | 41 const gfx::Size& max_size, |
| 42 int id) { | 42 int id) { |
| 43 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 43 DCHECK(!BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 44 BrowserThread::PostTask( | 44 BrowserThread::PostTask( |
| 45 BrowserThread::FILE, FROM_HERE, | 45 BrowserThread::FILE, FROM_HERE, |
| 46 NewRunnableMethod(this, &ImageLoader::LoadOnFileThread, resource, | 46 NewRunnableMethod(this, &ImageLoader::LoadOnFileThread, resource, |
| 47 max_size, id)); | 47 max_size, id)); |
| 48 } | 48 } |
| 49 | 49 |
| 50 void LoadOnFileThread(ExtensionResource resource, | 50 void LoadOnFileThread(const ExtensionResource& resource, |
| 51 const gfx::Size& max_size, | 51 const gfx::Size& max_size, |
| 52 int id) { | 52 int id) { |
| 53 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); | 53 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::FILE)); |
| 54 | 54 |
| 55 // Read the file from disk. | 55 // Read the file from disk. |
| 56 std::string file_contents; | 56 std::string file_contents; |
| 57 FilePath path = resource.GetFilePath(); | 57 FilePath path = resource.GetFilePath(); |
| 58 if (path.empty() || !file_util::ReadFileToString(path, &file_contents)) { | 58 if (path.empty() || !file_util::ReadFileToString(path, &file_contents)) { |
| 59 ReportBack(NULL, resource, gfx::Size(), id); | 59 ReportBack(NULL, resource, gfx::Size(), id); |
| 60 return; | 60 return; |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 // Remove all entries in the load_map_ referencing the extension. This ensures | 190 // Remove all entries in the load_map_ referencing the extension. This ensures |
| 191 // we don't attempt to cache the image when the load completes. | 191 // we don't attempt to cache the image when the load completes. |
| 192 for (LoadMap::iterator i = load_map_.begin(); i != load_map_.end();) { | 192 for (LoadMap::iterator i = load_map_.begin(); i != load_map_.end();) { |
| 193 if (i->second == extension) { | 193 if (i->second == extension) { |
| 194 load_map_.erase(i++); | 194 load_map_.erase(i++); |
| 195 } else { | 195 } else { |
| 196 ++i; | 196 ++i; |
| 197 } | 197 } |
| 198 } | 198 } |
| 199 } | 199 } |
| OLD | NEW |