summaryrefslogtreecommitdiffstats
path: root/chrome/utility/image_writer/image_writer_handler.h
blob: cd4816e2c02e0d886e98f6f3dbe8f4fb2fad1990 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_UTILITY_IMAGE_WRITER_IMAGE_WRITER_HANDLER_H_
#define CHROME_UTILITY_IMAGE_WRITER_IMAGE_WRITER_HANDLER_H_

#include <string>

#include "chrome/utility/image_writer/image_writer.h"
#include "chrome/utility/utility_message_handler.h"
#include "ipc/ipc_message.h"

namespace base {
class FilePath;
}

namespace image_writer {

// A handler for messages related to writing images.  This class is added as a
// handler in ChromeContentUtilityClient.
class ImageWriterHandler : public UtilityMessageHandler {
 public:
  ImageWriterHandler();
  virtual ~ImageWriterHandler();

  // Methods for sending the different messages back to the browser process.
  // Generally should be called by chrome::image_writer::ImageWriter.
  virtual void SendSucceeded();
  virtual void SendCancelled();
  virtual void SendFailed(const std::string& message);
  virtual void SendProgress(int64 progress);

 private:
  virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;

  // Small wrapper for sending on the UtilityProcess.
  void Send(IPC::Message* msg);

  // Message handlers.
  void OnWriteStart(const base::FilePath& image, const base::FilePath& device);
  void OnVerifyStart(const base::FilePath& image, const base::FilePath& device);
  void OnCancel();

  scoped_ptr<ImageWriter> image_writer_;
};

}  // namespace image_writer

#endif  // CHROME_UTILITY_IMAGE_WRITER_IMAGE_WRITER_HANDLER_H_