Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2310)

Unified Diff: device/devices_app/devices_app.cc

Issue 1314273002: Manage UsbService lifetime in DeviceClient implementations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « device/device_tests.gyp ('k') | device/hid/hid_connection_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/devices_app/devices_app.cc
diff --git a/device/devices_app/devices_app.cc b/device/devices_app/devices_app.cc
index 4501f75540bacc2ddf64824d21fbf8acd2e80c2d..19f7ed84c00ed0fc4346eb902305a2015307162e 100644
--- a/device/devices_app/devices_app.cc
+++ b/device/devices_app/devices_app.cc
@@ -65,14 +65,20 @@ class AppDeviceClient : public DeviceClient {
public:
explicit AppDeviceClient(
scoped_refptr<base::SequencedTaskRunner> blocking_task_runner)
- : usb_service_(UsbService::GetInstance(blocking_task_runner)) {}
+ : blocking_task_runner_(blocking_task_runner) {}
~AppDeviceClient() override {}
private:
// DeviceClient:
- UsbService* GetUsbService() override { return usb_service_; }
+ UsbService* GetUsbService() override {
+ if (!usb_service_) {
+ usb_service_ = UsbService::Create(blocking_task_runner_);
+ }
+ return usb_service_.get();
+ }
- UsbService* usb_service_;
+ scoped_refptr<base::SequencedTaskRunner> blocking_task_runner_;
+ scoped_ptr<UsbService> usb_service_;
};
} // namespace
« no previous file with comments | « device/device_tests.gyp ('k') | device/hid/hid_connection_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698