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

Unified 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, 5 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
Index: webkit/fileapi/media/media_device_map_service.cc
diff --git a/webkit/fileapi/media/media_device_map_service.cc b/webkit/fileapi/media/media_device_map_service.cc
new file mode 100644
index 0000000000000000000000000000000000000000..b0a1282c0a144b64f939a70c3a67f6c1226b5a51
--- /dev/null
+++ b/webkit/fileapi/media/media_device_map_service.cc
@@ -0,0 +1,68 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "webkit/fileapi/media/media_device_map_service.h"
+
+#include <utility>
+
+#include "webkit/fileapi/isolated_context.h"
+
+namespace fileapi {
+
+using base::SequencedTaskRunner;
+
+namespace {
+
+IsolatedContext* isolated_context() {
+ return IsolatedContext::GetInstance();
+}
+
+FilePath::StringType GetMediaDeviceLocation(const std::string& filesystem_id) {
+ FilePath root_path;
+ if (!isolated_context()->GetRegisteredPath(filesystem_id, &root_path))
+ 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.
+ return root_path.value();
+}
+
+} // namespace
+
+// static
+MediaDeviceMapService* MediaDeviceMapService::GetInstance() {
+ return Singleton<MediaDeviceMapService>::get();
+}
+
+MediaDeviceInterfaceImpl* MediaDeviceMapService::CreateOrGetMediaDevice(
+ const std::string& filesystem_id,
+ SequencedTaskRunner* media_task_runner) {
+ DCHECK(media_task_runner);
+
+ base::AutoLock lock(media_device_map_lock_);
+ FilePath::StringType device_location = GetMediaDeviceLocation(filesystem_id);
+ if (device_location.empty())
+ return NULL;
+
+ MediaDeviceMap::const_iterator it = media_device_map_.find(device_location);
+ if (it == media_device_map_.end()) {
+ media_device_map_.insert(std::make_pair(
+ device_location, new MediaDeviceInterfaceImpl(device_location,
+ media_task_runner)));
kinuko 2012/08/02 04:27:05 nit: weird indentation
kmadhusu 2012/08/02 16:59:03 Done.
+ }
+ return media_device_map_[device_location].get();
+}
+
+void MediaDeviceMapService::RemoveMediaDevice(
+ const std::string& device_location) {
+ base::AutoLock lock(media_device_map_lock_);
+ MediaDeviceMap::iterator it = media_device_map_.find(device_location);
+ if (it != media_device_map_.end())
+ media_device_map_.erase(it);
+}
+
+MediaDeviceMapService::MediaDeviceMapService() {
+}
+
+MediaDeviceMapService::~MediaDeviceMapService() {
+}
+
+} // namespace fileapi

Powered by Google App Engine
This is Rietveld 408576698