1 // Copyright 2013 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 CHROME_BROWSER_MEDIA_GALLERIES_LINUX_MTP_DEVICE_TASK_HELPER_MAP_SERVICE_H_
6 #define CHROME_BROWSER_MEDIA_GALLERIES_LINUX_MTP_DEVICE_TASK_HELPER_MAP_SERVICE_H_
11 #include "base/lazy_instance.h"
13 class MTPDeviceTaskHelper
;
15 // MTPDeviceTaskHelperMapService manages MTPDeviceTaskHelper objects.
16 // MTPDeviceTaskHelperMapService lives on the UI thread.
17 class MTPDeviceTaskHelperMapService
{
19 static MTPDeviceTaskHelperMapService
* GetInstance();
21 // Creates and returns the MTPDeviceTaskHelper object for the storage device
22 // specified by the |storage_name|.
23 MTPDeviceTaskHelper
* CreateDeviceTaskHelper(const std::string
& storage_name
);
25 // Destroys the MTPDeviceTaskHelper object created by
26 // CreateDeviceTaskHelper().
27 // |storage_name| specifies the name of the storage device.
28 void DestroyDeviceTaskHelper(const std::string
& storage_name
);
30 // Gets the MTPDeviceTaskHelper object associated with the device storage.
31 // |storage_name| specifies the name of the storage device.
32 // Return NULL if the |storage_name| is no longer valid (e.g. because the
33 // corresponding storage device is detached, etc).
34 MTPDeviceTaskHelper
* GetDeviceTaskHelper(const std::string
& storage_name
);
37 friend struct base::DefaultLazyInstanceTraits
<MTPDeviceTaskHelperMapService
>;
40 // Value: MTPDeviceTaskHelper object.
41 typedef std::map
<std::string
, MTPDeviceTaskHelper
*> TaskHelperMap
;
43 // Get access to this class using GetInstance() method.
44 MTPDeviceTaskHelperMapService();
45 ~MTPDeviceTaskHelperMapService();
47 // Mapping of |storage_name| and MTPDeviceTaskHelper*.
48 // TaskHelperMap owns MTPDeviceTaskHelper objects.
49 TaskHelperMap task_helper_map_
;
51 DISALLOW_COPY_AND_ASSIGN(MTPDeviceTaskHelperMapService
);
54 #endif // CHROME_BROWSER_MEDIA_GALLERIES_LINUX_MTP_DEVICE_TASK_HELPER_MAP_SERVICE_H_