OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/download/download_commands.h" | 5 #include "chrome/browser/download/download_commands.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 // Constructor must be called in the UI thread. | 59 // Constructor must be called in the UI thread. |
60 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 60 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
61 | 61 |
62 content::BrowserThread::GetBlockingPool()->PostTask( | 62 content::BrowserThread::GetBlockingPool()->PostTask( |
63 FROM_HERE, base::BindOnce(&ImageClipboardCopyManager::StartDecoding, | 63 FROM_HERE, base::BindOnce(&ImageClipboardCopyManager::StartDecoding, |
64 base::Unretained(this))); | 64 base::Unretained(this))); |
65 } | 65 } |
66 | 66 |
67 void StartDecoding() { | 67 void StartDecoding() { |
68 DCHECK(content::BrowserThread::GetBlockingPool()-> | 68 DCHECK(content::BrowserThread::GetBlockingPool()-> |
69 RunsTasksOnCurrentThread()); | 69 RunsTasksInCurrentSequence()); |
70 | 70 |
71 // Re-check the filesize since the file may be modified after downloaded. | 71 // Re-check the filesize since the file may be modified after downloaded. |
72 int64_t filesize; | 72 int64_t filesize; |
73 if (!GetFileSize(file_path_, &filesize) || | 73 if (!GetFileSize(file_path_, &filesize) || |
74 filesize > kMaxImageClipboardSize) { | 74 filesize > kMaxImageClipboardSize) { |
75 OnFailedBeforeDecoding(); | 75 OnFailedBeforeDecoding(); |
76 return; | 76 return; |
77 } | 77 } |
78 | 78 |
79 std::string data; | 79 std::string data; |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 download_item_->GetReceivedBytes() > kMaxImageClipboardSize) { | 402 download_item_->GetReceivedBytes() > kMaxImageClipboardSize) { |
403 return; | 403 return; |
404 } | 404 } |
405 | 405 |
406 if (!DownloadItemModel(download_item_).HasSupportedImageMimeType()) | 406 if (!DownloadItemModel(download_item_).HasSupportedImageMimeType()) |
407 return; | 407 return; |
408 | 408 |
409 base::FilePath file_path = download_item_->GetFullPath(); | 409 base::FilePath file_path = download_item_->GetFullPath(); |
410 ImageClipboardCopyManager::Start(file_path); | 410 ImageClipboardCopyManager::Start(file_path); |
411 } | 411 } |
OLD | NEW |