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