| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chromeos/dbus/image_burner_client.h" | 5 #include "chromeos/dbus/image_burner_client.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "dbus/bus.h" | 9 #include "dbus/bus.h" |
| 10 #include "dbus/message.h" | 10 #include "dbus/message.h" |
| 11 #include "dbus/object_path.h" | 11 #include "dbus/object_path.h" |
| 12 #include "dbus/object_proxy.h" | 12 #include "dbus/object_proxy.h" |
| 13 #include "third_party/cros_system_api/dbus/service_constants.h" | 13 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 14 | 14 |
| 15 namespace chromeos { | 15 namespace chromeos { |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 // The ImageBurnerClient implementation. | 19 // The ImageBurnerClient implementation. |
| 20 class ImageBurnerClientImpl : public ImageBurnerClient { | 20 class ImageBurnerClientImpl : public ImageBurnerClient { |
| 21 public: | 21 public: |
| 22 ImageBurnerClientImpl() : proxy_(NULL), weak_ptr_factory_(this) {} | 22 ImageBurnerClientImpl() : proxy_(NULL), weak_ptr_factory_(this) {} |
| 23 | 23 |
| 24 virtual ~ImageBurnerClientImpl() {} | 24 virtual ~ImageBurnerClientImpl() {} |
| 25 | 25 |
| 26 // ImageBurnerClient override. | 26 // ImageBurnerClient override. |
| 27 virtual void BurnImage(const std::string& from_path, | 27 virtual void BurnImage(const std::string& from_path, |
| 28 const std::string& to_path, | 28 const std::string& to_path, |
| 29 const ErrorCallback& error_callback) OVERRIDE { | 29 const ErrorCallback& error_callback) override { |
| 30 dbus::MethodCall method_call(imageburn::kImageBurnServiceInterface, | 30 dbus::MethodCall method_call(imageburn::kImageBurnServiceInterface, |
| 31 imageburn::kBurnImage); | 31 imageburn::kBurnImage); |
| 32 dbus::MessageWriter writer(&method_call); | 32 dbus::MessageWriter writer(&method_call); |
| 33 writer.AppendString(from_path); | 33 writer.AppendString(from_path); |
| 34 writer.AppendString(to_path); | 34 writer.AppendString(to_path); |
| 35 proxy_->CallMethod(&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, | 35 proxy_->CallMethod(&method_call, dbus::ObjectProxy::TIMEOUT_USE_DEFAULT, |
| 36 base::Bind(&ImageBurnerClientImpl::OnBurnImage, | 36 base::Bind(&ImageBurnerClientImpl::OnBurnImage, |
| 37 weak_ptr_factory_.GetWeakPtr(), | 37 weak_ptr_factory_.GetWeakPtr(), |
| 38 error_callback)); | 38 error_callback)); |
| 39 } | 39 } |
| 40 | 40 |
| 41 // ImageBurnerClient override. | 41 // ImageBurnerClient override. |
| 42 virtual void SetEventHandlers( | 42 virtual void SetEventHandlers( |
| 43 const BurnFinishedHandler& burn_finished_handler, | 43 const BurnFinishedHandler& burn_finished_handler, |
| 44 const BurnProgressUpdateHandler& burn_progress_update_handler) OVERRIDE { | 44 const BurnProgressUpdateHandler& burn_progress_update_handler) override { |
| 45 burn_finished_handler_ = burn_finished_handler; | 45 burn_finished_handler_ = burn_finished_handler; |
| 46 burn_progress_update_handler_ = burn_progress_update_handler; | 46 burn_progress_update_handler_ = burn_progress_update_handler; |
| 47 } | 47 } |
| 48 | 48 |
| 49 // ImageBurnerClient override. | 49 // ImageBurnerClient override. |
| 50 virtual void ResetEventHandlers() OVERRIDE { | 50 virtual void ResetEventHandlers() override { |
| 51 burn_finished_handler_.Reset(); | 51 burn_finished_handler_.Reset(); |
| 52 burn_progress_update_handler_.Reset(); | 52 burn_progress_update_handler_.Reset(); |
| 53 } | 53 } |
| 54 | 54 |
| 55 protected: | 55 protected: |
| 56 virtual void Init(dbus::Bus* bus) OVERRIDE { | 56 virtual void Init(dbus::Bus* bus) override { |
| 57 proxy_ = | 57 proxy_ = |
| 58 bus->GetObjectProxy(imageburn::kImageBurnServiceName, | 58 bus->GetObjectProxy(imageburn::kImageBurnServiceName, |
| 59 dbus::ObjectPath(imageburn::kImageBurnServicePath)); | 59 dbus::ObjectPath(imageburn::kImageBurnServicePath)); |
| 60 proxy_->ConnectToSignal( | 60 proxy_->ConnectToSignal( |
| 61 imageburn::kImageBurnServiceInterface, | 61 imageburn::kImageBurnServiceInterface, |
| 62 imageburn::kSignalBurnFinishedName, | 62 imageburn::kSignalBurnFinishedName, |
| 63 base::Bind(&ImageBurnerClientImpl::OnBurnFinished, | 63 base::Bind(&ImageBurnerClientImpl::OnBurnFinished, |
| 64 weak_ptr_factory_.GetWeakPtr()), | 64 weak_ptr_factory_.GetWeakPtr()), |
| 65 base::Bind(&ImageBurnerClientImpl::OnSignalConnected, | 65 base::Bind(&ImageBurnerClientImpl::OnSignalConnected, |
| 66 weak_ptr_factory_.GetWeakPtr())); | 66 weak_ptr_factory_.GetWeakPtr())); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 | 141 |
| 142 ImageBurnerClient::~ImageBurnerClient() { | 142 ImageBurnerClient::~ImageBurnerClient() { |
| 143 } | 143 } |
| 144 | 144 |
| 145 // static | 145 // static |
| 146 ImageBurnerClient* ImageBurnerClient::Create() { | 146 ImageBurnerClient* ImageBurnerClient::Create() { |
| 147 return new ImageBurnerClientImpl(); | 147 return new ImageBurnerClientImpl(); |
| 148 } | 148 } |
| 149 | 149 |
| 150 } // namespace chromeos | 150 } // namespace chromeos |
| OLD | NEW |