| OLD | NEW |
| 1 // Copyright (c) 2011 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 "chrome/browser/chromeos/dbus/cros_dbus_service.h" | 5 #include "chrome/browser/chromeos/dbus/cros_dbus_service.h" |
| 6 | 6 |
| 7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
| 8 #include "base/threading/platform_thread.h" | 8 #include "base/threading/platform_thread.h" |
| 9 #include "chrome/browser/chromeos/dbus/proxy_resolution_service_provider.h" | 9 #include "chrome/browser/chromeos/dbus/proxy_resolution_service_provider.h" |
| 10 #include "chrome/browser/chromeos/system/runtime_environment.h" | 10 #include "chrome/browser/chromeos/system/runtime_environment.h" |
| 11 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
| 12 #include "dbus/bus.h" | 12 #include "dbus/bus.h" |
| 13 #include "dbus/exported_object.h" | 13 #include "dbus/exported_object.h" |
| 14 #include "dbus/object_path.h" |
| 14 #include "third_party/cros_system_api/dbus/service_constants.h" | 15 #include "third_party/cros_system_api/dbus/service_constants.h" |
| 15 | 16 |
| 16 namespace chromeos { | 17 namespace chromeos { |
| 17 | 18 |
| 18 // The CrosDBusService implementation used in production, and unit tests. | 19 // The CrosDBusService implementation used in production, and unit tests. |
| 19 class CrosDBusServiceImpl : public CrosDBusService { | 20 class CrosDBusServiceImpl : public CrosDBusService { |
| 20 public: | 21 public: |
| 21 explicit CrosDBusServiceImpl(dbus::Bus* bus) | 22 explicit CrosDBusServiceImpl(dbus::Bus* bus) |
| 22 : service_started_(false), | 23 : service_started_(false), |
| 23 origin_thread_id_(base::PlatformThread::CurrentId()), | 24 origin_thread_id_(base::PlatformThread::CurrentId()), |
| 24 bus_(bus) { | 25 bus_(bus) { |
| 25 } | 26 } |
| 26 | 27 |
| 27 virtual ~CrosDBusServiceImpl() { | 28 virtual ~CrosDBusServiceImpl() { |
| 28 STLDeleteElements(&service_providers_); | 29 STLDeleteElements(&service_providers_); |
| 29 } | 30 } |
| 30 | 31 |
| 31 // CrosDBusService override. | 32 // CrosDBusService override. |
| 32 virtual void Start() { | 33 virtual void Start() { |
| 33 // Make sure we're running on the origin thread (i.e. the UI thread in | 34 // Make sure we're running on the origin thread (i.e. the UI thread in |
| 34 // production). | 35 // production). |
| 35 DCHECK(OnOriginThread()); | 36 DCHECK(OnOriginThread()); |
| 36 | 37 |
| 37 // Return if the service has been already started. | 38 // Return if the service has been already started. |
| 38 if (service_started_) | 39 if (service_started_) |
| 39 return; | 40 return; |
| 40 | 41 |
| 41 exported_object_ = bus_->GetExportedObject( | 42 exported_object_ = bus_->GetExportedObject( |
| 42 kLibCrosServiceName, | 43 kLibCrosServiceName, |
| 43 kLibCrosServicePath); | 44 dbus::ObjectPath(kLibCrosServicePath)); |
| 44 | 45 |
| 45 for (size_t i = 0; i < service_providers_.size(); ++i) | 46 for (size_t i = 0; i < service_providers_.size(); ++i) |
| 46 service_providers_[i]->Start(exported_object_); | 47 service_providers_[i]->Start(exported_object_); |
| 47 | 48 |
| 48 service_started_ = true; | 49 service_started_ = true; |
| 49 | 50 |
| 50 VLOG(1) << "CrosDBusServiceImpl started."; | 51 VLOG(1) << "CrosDBusServiceImpl started."; |
| 51 } | 52 } |
| 52 | 53 |
| 53 // Registers a service provider. This must be done before Start(). | 54 // Registers a service provider. This must be done before Start(). |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 return service; | 107 return service; |
| 107 } | 108 } |
| 108 | 109 |
| 109 CrosDBusService::~CrosDBusService() { | 110 CrosDBusService::~CrosDBusService() { |
| 110 } | 111 } |
| 111 | 112 |
| 112 CrosDBusService::ServiceProviderInterface::~ServiceProviderInterface() { | 113 CrosDBusService::ServiceProviderInterface::~ServiceProviderInterface() { |
| 113 } | 114 } |
| 114 | 115 |
| 115 } // namespace chromeos | 116 } // namespace chromeos |
| OLD | NEW |