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

Side by Side Diff: content/browser/renderer_host/clipboard_message_filter.cc

Issue 2839793002: Use TaskScheduler instead of blocking pool in clipboard_message_filter.cc. (Closed)
Patch Set: self-review Created 3 years, 8 months 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
« no previous file with comments | « no previous file | no next file » | 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) 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 "content/browser/renderer_host/clipboard_message_filter.h" 5 #include "content/browser/renderer_host/clipboard_message_filter.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/location.h" 11 #include "base/location.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/pickle.h" 13 #include "base/pickle.h"
14 #include "base/strings/utf_string_conversions.h" 14 #include "base/strings/utf_string_conversions.h"
15 #include "base/threading/sequenced_worker_pool.h" 15 #include "base/task_scheduler/post_task.h"
16 #include "base/threading/thread_task_runner_handle.h" 16 #include "base/threading/thread_task_runner_handle.h"
17 #include "build/build_config.h" 17 #include "build/build_config.h"
18 #include "content/browser/blob_storage/chrome_blob_storage_context.h" 18 #include "content/browser/blob_storage/chrome_blob_storage_context.h"
19 #include "content/common/clipboard_messages.h" 19 #include "content/common/clipboard_messages.h"
20 #include "content/public/browser/blob_handle.h" 20 #include "content/public/browser/blob_handle.h"
21 #include "content/public/browser/browser_context.h" 21 #include "content/public/browser/browser_context.h"
22 #include "ipc/ipc_message_macros.h" 22 #include "ipc/ipc_message_macros.h"
23 #include "third_party/skia/include/core/SkBitmap.h" 23 #include "third_party/skia/include/core/SkBitmap.h"
24 #include "ui/base/clipboard/clipboard.h" 24 #include "ui/base/clipboard/clipboard.h"
25 #include "ui/base/clipboard/custom_data_helper.h" 25 #include "ui/base/clipboard/custom_data_helper.h"
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 173
174 void ClipboardMessageFilter::OnReadRTF(ui::ClipboardType type, 174 void ClipboardMessageFilter::OnReadRTF(ui::ClipboardType type,
175 std::string* result) { 175 std::string* result) {
176 GetClipboard()->ReadRTF(type, result); 176 GetClipboard()->ReadRTF(type, result);
177 } 177 }
178 178
179 void ClipboardMessageFilter::OnReadImage(ui::ClipboardType type, 179 void ClipboardMessageFilter::OnReadImage(ui::ClipboardType type,
180 IPC::Message* reply_msg) { 180 IPC::Message* reply_msg) {
181 SkBitmap bitmap = GetClipboard()->ReadImage(type); 181 SkBitmap bitmap = GetClipboard()->ReadImage(type);
182 182
183 BrowserThread::GetBlockingPool() 183 base::PostTaskWithTraits(
184 ->GetTaskRunnerWithShutdownBehavior( 184 FROM_HERE,
185 base::SequencedWorkerPool::SKIP_ON_SHUTDOWN) 185 base::TaskTraits()
186 ->PostTask(FROM_HERE, 186 .MayBlock()
187 base::Bind(&ClipboardMessageFilter::ReadAndEncodeImage, this, 187 .WithPriority(base::TaskPriority::BACKGROUND)
188 bitmap, reply_msg)); 188 .WithShutdownBehavior(base::TaskShutdownBehavior::SKIP_ON_SHUTDOWN),
189 base::BindOnce(&ClipboardMessageFilter::ReadAndEncodeImage, this, bitmap,
190 reply_msg));
189 } 191 }
190 192
191 void ClipboardMessageFilter::ReadAndEncodeImage(const SkBitmap& bitmap, 193 void ClipboardMessageFilter::ReadAndEncodeImage(const SkBitmap& bitmap,
192 IPC::Message* reply_msg) { 194 IPC::Message* reply_msg) {
193 if (!bitmap.isNull()) { 195 if (!bitmap.isNull()) {
194 std::unique_ptr<std::vector<uint8_t>> png_data(new std::vector<uint8_t>); 196 std::unique_ptr<std::vector<uint8_t>> png_data(new std::vector<uint8_t>);
195 if (gfx::PNGCodec::FastEncodeBGRASkBitmap(bitmap, false, png_data.get())) { 197 if (gfx::PNGCodec::FastEncodeBGRASkBitmap(bitmap, false, png_data.get())) {
196 BrowserThread::PostTask( 198 BrowserThread::PostTask(
197 BrowserThread::IO, FROM_HERE, 199 BrowserThread::IO, FROM_HERE,
198 base::Bind(&ClipboardMessageFilter::OnReadAndEncodeImageFinished, 200 base::Bind(&ClipboardMessageFilter::OnReadAndEncodeImageFinished,
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 326
325 // static 327 // static
326 ui::Clipboard* ClipboardMessageFilter::GetClipboard() { 328 ui::Clipboard* ClipboardMessageFilter::GetClipboard() {
327 // We have a static instance of the clipboard service for use by all message 329 // We have a static instance of the clipboard service for use by all message
328 // filters. This instance lives for the life of the browser processes. 330 // filters. This instance lives for the life of the browser processes.
329 static ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread(); 331 static ui::Clipboard* clipboard = ui::Clipboard::GetForCurrentThread();
330 return clipboard; 332 return clipboard;
331 } 333 }
332 334
333 } // namespace content 335 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698