• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #ifndef CHROMEOS_DBUS_IMAGE_BURNER_CLIENT_H_
6 #define CHROMEOS_DBUS_IMAGE_BURNER_CLIENT_H_
7 
8 #include <string>
9 
10 #include "base/basictypes.h"
11 #include "base/callback.h"
12 #include "chromeos/chromeos_export.h"
13 #include "chromeos/dbus/dbus_client.h"
14 
15 namespace chromeos {
16 
17 // ImageBurnerClient is used to communicate with the image burner.
18 // All method should be called from the origin thread (UI thread) which
19 // initializes the DBusThreadManager instance.
20 class CHROMEOS_EXPORT ImageBurnerClient : public DBusClient {
21  public:
22   virtual ~ImageBurnerClient();
23 
24   // A callback to be called when DBus method call fails.
25   typedef base::Callback<void()> ErrorCallback;
26 
27   // A callback to handle burn_finished signal.
28   typedef base::Callback<void(const std::string& target_path,
29                               bool success,
30                               const std::string& error)> BurnFinishedHandler;
31 
32   // A callback to handle burn_progress_update signal.
33   typedef base::Callback<void(const std::string& target_path,
34                               int64 num_bytes_burnt,
35                               int64 total_size)> BurnProgressUpdateHandler;
36 
37   // Burns the image |from_path| to the disk |to_path|.
38   virtual void BurnImage(const std::string& from_path,
39                          const std::string& to_path,
40                          const ErrorCallback& error_callback) = 0;
41 
42   // Sets callbacks as event handlers.
43   // |burn_finished_handler| is called when burn_finished signal is received.
44   // |burn_progress_update_handler| is called when burn_progress_update signal
45   // is received.
46   virtual void SetEventHandlers(
47       const BurnFinishedHandler& burn_finished_handler,
48       const BurnProgressUpdateHandler& burn_progress_update_handler) = 0;
49 
50   // Resets event handlers. After calling this method, nothing is done when
51   // signals are received.
52   virtual void ResetEventHandlers() = 0;
53 
54   // Factory function, creates a new instance and returns ownership.
55   // For normal usage, access the singleton via DBusThreadManager::Get().
56   static ImageBurnerClient* Create();
57 
58  protected:
59   // Create() should be used instead.
60   ImageBurnerClient();
61 
62  private:
63   DISALLOW_COPY_AND_ASSIGN(ImageBurnerClient);
64 };
65 
66 }  // namespace chromeos
67 
68 #endif  // CHROMEOS_DBUS_IMAGE_BURNER_CLIENT_H_
69