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

Side by Side Diff: chrome/browser/dom_ui/fileicon_source.cc

Issue 4192012: Convert implicit scoped_refptr constructor calls to explicit ones, part 1 (Closed) Base URL: http://git.chromium.org/git/chromium.git
Patch Set: fix presubmit Created 10 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/dom_ui/dom_ui_factory.cc ('k') | chrome/browser/dom_ui/new_tab_ui.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/dom_ui/fileicon_source.h" 5 #include "chrome/browser/dom_ui/fileicon_source.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/file_path.h" 8 #include "base/file_path.h"
9 #include "base/ref_counted_memory.h" 9 #include "base/ref_counted_memory.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 25 matching lines...) Expand all
36 // this only appears to matter for getting icons from .exe files. 36 // this only appears to matter for getting icons from .exe files.
37 std::replace(escaped_path.begin(), escaped_path.end(), '/', '\\'); 37 std::replace(escaped_path.begin(), escaped_path.end(), '/', '\\');
38 FilePath escaped_filepath(UTF8ToWide(escaped_path)); 38 FilePath escaped_filepath(UTF8ToWide(escaped_path));
39 #elif defined(OS_POSIX) 39 #elif defined(OS_POSIX)
40 // The correct encoding on Linux may not actually be UTF8. 40 // The correct encoding on Linux may not actually be UTF8.
41 FilePath escaped_filepath(escaped_path); 41 FilePath escaped_filepath(escaped_path);
42 #endif 42 #endif
43 SkBitmap* icon = im->LookupIcon(escaped_filepath, IconLoader::NORMAL); 43 SkBitmap* icon = im->LookupIcon(escaped_filepath, IconLoader::NORMAL);
44 44
45 if (icon) { 45 if (icon) {
46 scoped_refptr<RefCountedBytes> icon_data = new RefCountedBytes; 46 scoped_refptr<RefCountedBytes> icon_data(new RefCountedBytes);
47 gfx::PNGCodec::EncodeBGRASkBitmap(*icon, false, &icon_data->data); 47 gfx::PNGCodec::EncodeBGRASkBitmap(*icon, false, &icon_data->data);
48 48
49 SendResponse(request_id, icon_data); 49 SendResponse(request_id, icon_data);
50 } else { 50 } else {
51 // Icon was not in cache, go fetch it slowly. 51 // Icon was not in cache, go fetch it slowly.
52 IconManager::Handle h = im->LoadIcon(escaped_filepath, 52 IconManager::Handle h = im->LoadIcon(escaped_filepath,
53 IconLoader::NORMAL, 53 IconLoader::NORMAL,
54 &cancelable_consumer_, 54 &cancelable_consumer_,
55 NewCallback(this, &FileIconSource::OnFileIconDataAvailable)); 55 NewCallback(this, &FileIconSource::OnFileIconDataAvailable));
56 56
57 // Attach the ChromeURLDataManager request ID to the history request. 57 // Attach the ChromeURLDataManager request ID to the history request.
58 cancelable_consumer_.SetClientData(im, h, request_id); 58 cancelable_consumer_.SetClientData(im, h, request_id);
59 } 59 }
60 } 60 }
61 61
62 void FileIconSource::OnFileIconDataAvailable(IconManager::Handle handle, 62 void FileIconSource::OnFileIconDataAvailable(IconManager::Handle handle,
63 SkBitmap* icon) { 63 SkBitmap* icon) {
64 IconManager* im = g_browser_process->icon_manager(); 64 IconManager* im = g_browser_process->icon_manager();
65 int request_id = cancelable_consumer_.GetClientData(im, handle); 65 int request_id = cancelable_consumer_.GetClientData(im, handle);
66 66
67 if (icon) { 67 if (icon) {
68 scoped_refptr<RefCountedBytes> icon_data = new RefCountedBytes; 68 scoped_refptr<RefCountedBytes> icon_data(new RefCountedBytes);
69 gfx::PNGCodec::EncodeBGRASkBitmap(*icon, false, &icon_data->data); 69 gfx::PNGCodec::EncodeBGRASkBitmap(*icon, false, &icon_data->data);
70 70
71 SendResponse(request_id, icon_data); 71 SendResponse(request_id, icon_data);
72 } else { 72 } else {
73 // TODO(glen): send a dummy icon. 73 // TODO(glen): send a dummy icon.
74 SendResponse(request_id, NULL); 74 SendResponse(request_id, NULL);
75 } 75 }
76 } 76 }
OLDNEW
« no previous file with comments | « chrome/browser/dom_ui/dom_ui_factory.cc ('k') | chrome/browser/dom_ui/new_tab_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698