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