| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 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_ | |
| 7 | |
| 8 #include <map> | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/lazy_instance.h" | |
| 12 #include "base/macros.h" | |
| 13 | |
| 14 class MTPDeviceTaskHelper; | |
| 15 | |
| 16 // MTPDeviceTaskHelperMapService manages MTPDeviceTaskHelper objects. | |
| 17 // MTPDeviceTaskHelperMapService lives on the UI thread. | |
| 18 class MTPDeviceTaskHelperMapService { | |
| 19 public: | |
| 20 static MTPDeviceTaskHelperMapService* GetInstance(); | |
| 21 | |
| 22 // Creates and returns the MTPDeviceTaskHelper object for the storage device | |
| 23 // specified by the |storage_name|. | |
| 24 MTPDeviceTaskHelper* CreateDeviceTaskHelper(const std::string& storage_name, | |
| 25 const bool read_only); | |
| 26 | |
| 27 // Destroys the MTPDeviceTaskHelper object created by | |
| 28 // CreateDeviceTaskHelper(). | |
| 29 // |storage_name| specifies the name of the storage device. | |
| 30 void DestroyDeviceTaskHelper(const std::string& storage_name, | |
| 31 const bool read_only); | |
| 32 | |
| 33 // Gets the MTPDeviceTaskHelper object associated with the device storage. | |
| 34 // |storage_name| specifies the name of the storage device. | |
| 35 // Return NULL if the |storage_name| is no longer valid (e.g. because the | |
| 36 // corresponding storage device is detached, etc). | |
| 37 MTPDeviceTaskHelper* GetDeviceTaskHelper(const std::string& storage_name, | |
| 38 const bool read_only); | |
| 39 | |
| 40 private: | |
| 41 friend struct base::DefaultLazyInstanceTraits<MTPDeviceTaskHelperMapService>; | |
| 42 | |
| 43 // A key to be used in TaskHelperMap. | |
| 44 typedef std::string MTPDeviceTaskHelperKey; | |
| 45 | |
| 46 // Gets a key from |storage_name| and |read_only|. | |
| 47 static MTPDeviceTaskHelperKey GetMTPDeviceTaskHelperKey( | |
| 48 const std::string& storage_name, | |
| 49 const bool read_only); | |
| 50 | |
| 51 // Key: A combined value with storage_name and read_only. | |
| 52 // Value: MTPDeviceTaskHelper object. | |
| 53 typedef std::map<MTPDeviceTaskHelperKey, MTPDeviceTaskHelper*> TaskHelperMap; | |
| 54 | |
| 55 // Get access to this class using GetInstance() method. | |
| 56 MTPDeviceTaskHelperMapService(); | |
| 57 ~MTPDeviceTaskHelperMapService(); | |
| 58 | |
| 59 // Mapping of |storage_name| and MTPDeviceTaskHelper*. | |
| 60 // TaskHelperMap owns MTPDeviceTaskHelper objects. | |
| 61 TaskHelperMap task_helper_map_; | |
| 62 | |
| 63 DISALLOW_COPY_AND_ASSIGN(MTPDeviceTaskHelperMapService); | |
| 64 }; | |
| 65 | |
| 66 #endif // CHROME_BROWSER_MEDIA_GALLERIES_LINUX_MTP_DEVICE_TASK_HELPER_MAP_SERVI
CE_H_ | |
| OLD | NEW |