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

Side by Side Diff: webkit/fileapi/media/media_device_map_service.cc

Issue 10781014: Isolated FS for media devices. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Device intent source (media detach notification) Created 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "webkit/fileapi/media/media_device_map_service.h"
6
7 #include <utility>
8
9 #include "webkit/fileapi/isolated_context.h"
10
11 namespace fileapi {
12
13 using base::SequencedTaskRunner;
14
15 namespace {
16
17 IsolatedContext* isolated_context() {
18 return IsolatedContext::GetInstance();
19 }
20
21 FilePath::StringType GetMediaDeviceLocation(const std::string& filesystem_id) {
22 FilePath root_path;
23 if (!isolated_context()->GetRegisteredPath(filesystem_id, &root_path))
24 NOTREACHED();
kinuko 2012/08/02 04:27:05 Please remove this NOTREACHED(), this could return
kmadhusu 2012/08/02 16:59:03 Fixed and removed the helper functions.
25 return root_path.value();
26 }
27
28 } // namespace
29
30 // static
31 MediaDeviceMapService* MediaDeviceMapService::GetInstance() {
32 return Singleton<MediaDeviceMapService>::get();
33 }
34
35 MediaDeviceInterfaceImpl* MediaDeviceMapService::CreateOrGetMediaDevice(
36 const std::string& filesystem_id,
37 SequencedTaskRunner* media_task_runner) {
38 DCHECK(media_task_runner);
39
40 base::AutoLock lock(media_device_map_lock_);
41 FilePath::StringType device_location = GetMediaDeviceLocation(filesystem_id);
42 if (device_location.empty())
43 return NULL;
44
45 MediaDeviceMap::const_iterator it = media_device_map_.find(device_location);
46 if (it == media_device_map_.end()) {
47 media_device_map_.insert(std::make_pair(
48 device_location, new MediaDeviceInterfaceImpl(device_location,
49 media_task_runner)));
kinuko 2012/08/02 04:27:05 nit: weird indentation
kmadhusu 2012/08/02 16:59:03 Done.
50 }
51 return media_device_map_[device_location].get();
52 }
53
54 void MediaDeviceMapService::RemoveMediaDevice(
55 const std::string& device_location) {
56 base::AutoLock lock(media_device_map_lock_);
57 MediaDeviceMap::iterator it = media_device_map_.find(device_location);
58 if (it != media_device_map_.end())
59 media_device_map_.erase(it);
60 }
61
62 MediaDeviceMapService::MediaDeviceMapService() {
63 }
64
65 MediaDeviceMapService::~MediaDeviceMapService() {
66 }
67
68 } // namespace fileapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698