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

Side by Side Diff: chrome/browser/image_writer/image_writer.cc

Issue 61643015: Adds imageWriterPrivate support for Windows (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reorganization and test updates. Created 7 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/bind.h"
6 #include "chrome/browser/browser_process.h"
7 #include "chrome/browser/image_writer/image_writer.h"
8 #include "chrome/common/chrome_utility_messages.h"
9 #include "content/public/browser/browser_thread.h"
10 #include "content/public/browser/utility_process_host.h"
11
12 using content::BrowserThread;
13 using content::UtilityProcessHost;
14
15 ImageWriter::ImageWriter(Delegate* delegate,
16 const base::FilePath& source,
17 const base::FilePath& target)
18 : delegate_(delegate),
19 source_(source),
20 target_(target) {
21 }
22
23 ImageWriter::~ImageWriter() {}
24
25 void ImageWriter::Start(scoped_refptr<base::SequencedTaskRunner> task_runner) {
26 task_runner_ = task_runner;
27 BrowserThread::PostTask(
28 BrowserThread::IO,
29 FROM_HERE,
30 base::Bind(&ImageWriter::StartWriteInUtilityProcess, this));
31 }
32
33 bool ImageWriter::OnMessageReceived(const IPC::Message& message) {
34 bool handled = true;
35 IPC_BEGIN_MESSAGE_MAP(ImageWriter, message)
36 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_ImageWriter_Succeeded,
37 OnWriteImageSucceeded)
38 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_ImageWriter_Failed,
39 OnWriteImageFailed)
40 IPC_MESSAGE_HANDLER(ChromeUtilityHostMsg_ImageWriter_Progress,
41 OnWriteImageProgress)
42 IPC_MESSAGE_UNHANDLED(handled = false)
43 IPC_END_MESSAGE_MAP()
44 return handled;
45 }
46
47 void ImageWriter::OnWriteImageSucceeded() {
48 if (delegate_)
49 delegate_->OnWriteImageSucceeded();
50 }
51
52 void ImageWriter::OnWriteImageFailed(const std::string& message) {
53 if (delegate_)
54 delegate_->OnWriteImageFailed(message);
55 }
56
57 void ImageWriter::OnWriteImageProgress(int progress) {
58 if (delegate_)
59 delegate_->OnWriteImageProgress(progress);
60 }
61
62 void ImageWriter::StartWriteInUtilityProcess() {
63 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
64
65 DVLOG(0) << "Sending image write request.";
66
67 UtilityProcessHost* utility_process_host;
68 utility_process_host = UtilityProcessHost::Create(this, task_runner_.get());
69 utility_process_host->DisableSandbox();
70 if (!utility_process_host->Send(
71 new ChromeUtilityMsg_ImageWriter_Write(source_, target_))) {
72 DLOG(ERROR) << "Unable to send Write message to Utility Process.";
73 }
74 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698