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

Side by Side Diff: chrome/browser/media_galleries/linux/mtp_device_task_helper_map_service.cc

Issue 2358493002: Remove MTP support on Linux. (Closed)
Patch Set: move files Created 4 years, 2 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 unified diff | Download patch
OLDNEW
(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 #include "chrome/browser/media_galleries/linux/mtp_device_task_helper_map_servic e.h"
6
7 #include "base/logging.h"
8 #include "base/stl_util.h"
9 #include "chrome/browser/media_galleries/linux/mtp_device_task_helper.h"
10 #include "content/public/browser/browser_thread.h"
11
12 namespace {
13
14 base::LazyInstance<MTPDeviceTaskHelperMapService>
15 g_mtp_device_task_helper_map_service = LAZY_INSTANCE_INITIALIZER;
16
17 } // namespace
18
19 // static
20 MTPDeviceTaskHelperMapService* MTPDeviceTaskHelperMapService::GetInstance() {
21 return g_mtp_device_task_helper_map_service.Pointer();
22 }
23
24 MTPDeviceTaskHelper* MTPDeviceTaskHelperMapService::CreateDeviceTaskHelper(
25 const std::string& storage_name,
26 const bool read_only) {
27 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
28 DCHECK(!storage_name.empty());
29 const MTPDeviceTaskHelperKey key =
30 GetMTPDeviceTaskHelperKey(storage_name, read_only);
31 DCHECK(!base::ContainsKey(task_helper_map_, key));
32 MTPDeviceTaskHelper* task_helper = new MTPDeviceTaskHelper();
33 task_helper_map_[key] = task_helper;
34 return task_helper;
35 }
36
37 void MTPDeviceTaskHelperMapService::DestroyDeviceTaskHelper(
38 const std::string& storage_name,
39 const bool read_only) {
40 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
41 const MTPDeviceTaskHelperKey key =
42 GetMTPDeviceTaskHelperKey(storage_name, read_only);
43 TaskHelperMap::iterator it = task_helper_map_.find(key);
44 if (it == task_helper_map_.end())
45 return;
46 delete it->second;
47 task_helper_map_.erase(it);
48 }
49
50 MTPDeviceTaskHelper* MTPDeviceTaskHelperMapService::GetDeviceTaskHelper(
51 const std::string& storage_name,
52 const bool read_only) {
53 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
54 DCHECK(!storage_name.empty());
55 const MTPDeviceTaskHelperKey key =
56 GetMTPDeviceTaskHelperKey(storage_name, read_only);
57 TaskHelperMap::const_iterator it = task_helper_map_.find(key);
58 return (it != task_helper_map_.end()) ? it->second : NULL;
59 }
60
61 // static
62 MTPDeviceTaskHelperMapService::MTPDeviceTaskHelperKey
63 MTPDeviceTaskHelperMapService::GetMTPDeviceTaskHelperKey(
64 const std::string& storage_name,
65 const bool read_only) {
66 return (read_only ? "ReadOnly" : "ReadWrite") + std::string("|") +
67 storage_name;
68 }
69
70 MTPDeviceTaskHelperMapService::MTPDeviceTaskHelperMapService() {
71 }
72
73 MTPDeviceTaskHelperMapService::~MTPDeviceTaskHelperMapService() {
74 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698