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.
5 #ifndef CHROMEOS_DBUS_IMAGE_BURNER_CLIENT_H_
6 #define CHROMEOS_DBUS_IMAGE_BURNER_CLIENT_H_
10 #include "base/basictypes.h"
11 #include "base/callback.h"
12 #include "chromeos/chromeos_export.h"
13 #include "chromeos/dbus/dbus_client.h"
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
{
22 ~ImageBurnerClient() override
;
24 // A callback to be called when DBus method call fails.
25 typedef base::Callback
<void()> ErrorCallback
;
27 // A callback to handle burn_finished signal.
28 typedef base::Callback
<void(const std::string
& target_path
,
30 const std::string
& error
)> BurnFinishedHandler
;
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
;
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;
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
46 virtual void SetEventHandlers(
47 const BurnFinishedHandler
& burn_finished_handler
,
48 const BurnProgressUpdateHandler
& burn_progress_update_handler
) = 0;
50 // Resets event handlers. After calling this method, nothing is done when
51 // signals are received.
52 virtual void ResetEventHandlers() = 0;
54 // Factory function, creates a new instance and returns ownership.
55 // For normal usage, access the singleton via DBusThreadManager::Get().
56 static ImageBurnerClient
* Create();
59 // Create() should be used instead.
63 DISALLOW_COPY_AND_ASSIGN(ImageBurnerClient
);
66 } // namespace chromeos
68 #endif // CHROMEOS_DBUS_IMAGE_BURNER_CLIENT_H_