| OLD | NEW | 
|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/icon_loader.h" | 5 #include "chrome/browser/icon_loader.h" | 
| 6 | 6 | 
| 7 #include "base/bind.h" | 7 #include "base/bind.h" | 
| 8 #include "base/threading/thread_task_runner_handle.h" | 8 #include "base/threading/thread_task_runner_handle.h" | 
| 9 #include "content/public/browser/browser_thread.h" | 9 #include "content/public/browser/browser_thread.h" | 
| 10 | 10 | 
| 11 using content::BrowserThread; | 11 using content::BrowserThread; | 
| 12 | 12 | 
| 13 IconLoader::IconLoader(const base::FilePath& file_path, | 13 IconLoader::IconLoader(const base::FilePath& file_path, | 
| 14                        IconSize size, | 14                        IconSize size, | 
| 15                        Delegate* delegate) | 15                        Delegate* delegate) | 
| 16     : target_task_runner_(NULL), | 16     : file_path_(file_path), | 
| 17       file_path_(file_path), |  | 
| 18       icon_size_(size), | 17       icon_size_(size), | 
| 19       delegate_(delegate) {} | 18       delegate_(delegate) {} | 
| 20 | 19 | 
| 21 IconLoader::~IconLoader() { | 20 IconLoader::~IconLoader() { | 
| 22 } | 21 } | 
| 23 | 22 | 
| 24 void IconLoader::Start() { | 23 void IconLoader::Start() { | 
| 25   target_task_runner_ = base::ThreadTaskRunnerHandle::Get(); | 24   target_task_runner_ = base::ThreadTaskRunnerHandle::Get(); | 
| 26 | 25 | 
| 27   BrowserThread::PostTaskAndReply(BrowserThread::FILE, FROM_HERE, | 26   BrowserThread::PostTaskAndReply(BrowserThread::FILE, FROM_HERE, | 
| 28       base::Bind(&IconLoader::ReadGroup, this), | 27       base::Bind(&IconLoader::ReadGroup, this), | 
| 29       base::Bind(&IconLoader::OnReadGroup, this)); | 28       base::Bind(&IconLoader::OnReadGroup, this)); | 
| 30 } | 29 } | 
| 31 | 30 | 
| 32 void IconLoader::ReadGroup() { | 31 void IconLoader::ReadGroup() { | 
| 33   group_ = ReadGroupIDFromFilepath(file_path_); | 32   group_ = GroupForFilepath(file_path_); | 
| 34 } | 33 } | 
| 35 | 34 | 
| 36 void IconLoader::OnReadGroup() { | 35 void IconLoader::OnReadGroup() { | 
| 37   if (IsIconMutableFromFilepath(file_path_) || | 36   BrowserThread::PostTask(ReadIconThreadID(), FROM_HERE, | 
| 38       !delegate_->OnGroupLoaded(this, group_)) { | 37                           base::Bind(&IconLoader::ReadIcon, this)); | 
| 39     BrowserThread::PostTask(ReadIconThreadID(), FROM_HERE, |  | 
| 40         base::Bind(&IconLoader::ReadIcon, this)); |  | 
| 41   } |  | 
| 42 } | 38 } | 
| 43 | 39 | 
| 44 void IconLoader::NotifyDelegate() { | 40 void IconLoader::NotifyDelegate() { | 
| 45   // If the delegate takes ownership of the Image, release it from the scoped | 41   delegate_->OnImageLoaded(this, std::move(image_), group_); | 
| 46   // pointer. |  | 
| 47   if (delegate_->OnImageLoaded(this, image_.get(), group_)) |  | 
| 48     ignore_result(image_.release());  // Can't ignore return value. |  | 
| 49 } | 42 } | 
| OLD | NEW | 
|---|