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

Side by Side Diff: chrome/browser/chromeos/file_system_provider/mount_path_util.cc

Issue 258783006: [fsp] Add the getMetadata operation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed a lot. Created 6 years, 7 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
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/file_system_provider/mount_path_util.h" 5 #include "chrome/browser/chromeos/file_system_provider/mount_path_util.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
11 #include "chrome/browser/browser_process.h" 11 #include "chrome/browser/browser_process.h"
12 #include "chrome/browser/chromeos/file_system_provider/provided_file_system.h" 12 #include "chrome/browser/chromeos/file_system_provider/provided_file_system.h"
13 #include "chrome/browser/chromeos/file_system_provider/service.h" 13 #include "chrome/browser/chromeos/file_system_provider/service.h"
14 #include "chrome/browser/chromeos/login/user.h" 14 #include "chrome/browser/chromeos/login/user.h"
15 #include "chrome/browser/chromeos/login/user_manager.h" 15 #include "chrome/browser/chromeos/login/user_manager.h"
16 #include "chrome/browser/chromeos/profiles/profile_helper.h" 16 #include "chrome/browser/chromeos/profiles/profile_helper.h"
17 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/profiles/profile_manager.h" 18 #include "chrome/browser/profiles/profile_manager.h"
19 #include "content/public/browser/browser_thread.h"
20
21 using content::BrowserThread;
19 22
20 namespace chromeos { 23 namespace chromeos {
21 namespace file_system_provider { 24 namespace file_system_provider {
22 namespace util { 25 namespace util {
23 26
24 namespace { 27 namespace {
25 28
26 // Root mount path for all of the provided file systems. 29 // Root mount path for all of the provided file systems.
27 const base::FilePath::CharType kProvidedMountPointRoot[] = 30 const base::FilePath::CharType kProvidedMountPointRoot[] =
28 FILE_PATH_LITERAL("/provided"); 31 FILE_PATH_LITERAL("/provided");
(...skipping 14 matching lines...) Expand all
43 } 46 }
44 47
45 FileSystemURLParser::FileSystemURLParser(const fileapi::FileSystemURL& url) 48 FileSystemURLParser::FileSystemURLParser(const fileapi::FileSystemURL& url)
46 : url_(url), file_system_(NULL) { 49 : url_(url), file_system_(NULL) {
47 } 50 }
48 51
49 FileSystemURLParser::~FileSystemURLParser() { 52 FileSystemURLParser::~FileSystemURLParser() {
50 } 53 }
51 54
52 bool FileSystemURLParser::Parse() { 55 bool FileSystemURLParser::Parse() {
56 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
kinaba 2014/04/30 07:55:03 You can also use the recently introduced macro: DC
mtomasz 2014/04/30 09:18:24 Cool! Done.
57
53 if (url_.type() != fileapi::kFileSystemTypeProvided) 58 if (url_.type() != fileapi::kFileSystemTypeProvided)
54 return false; 59 return false;
55 60
56 // First, find the service handling the mount point of the URL. 61 // First, find the service handling the mount point of the URL.
57 const std::vector<Profile*>& profiles = 62 const std::vector<Profile*>& profiles =
58 g_browser_process->profile_manager()->GetLoadedProfiles(); 63 g_browser_process->profile_manager()->GetLoadedProfiles();
59 64
60 for (size_t i = 0; i < profiles.size(); ++i) { 65 for (size_t i = 0; i < profiles.size(); ++i) {
61 Profile* original_profile = profiles[i]->GetOriginalProfile(); 66 Profile* original_profile = profiles[i]->GetOriginalProfile();
62 67
(...skipping 10 matching lines...) Expand all
73 service->GetProvidedFileSystem(url_.filesystem_id()); 78 service->GetProvidedFileSystem(url_.filesystem_id());
74 if (!file_system) 79 if (!file_system)
75 continue; 80 continue;
76 81
77 // Strip the mount point name from the virtual path, to extract the file 82 // Strip the mount point name from the virtual path, to extract the file
78 // path within the provided file system. 83 // path within the provided file system.
79 file_system_ = file_system; 84 file_system_ = file_system;
80 std::vector<base::FilePath::StringType> components; 85 std::vector<base::FilePath::StringType> components;
81 url_.virtual_path().GetComponents(&components); 86 url_.virtual_path().GetComponents(&components);
82 DCHECK_LT(0u, components.size()); 87 DCHECK_LT(0u, components.size());
83 file_path_ = base::FilePath(); 88 file_path_ = base::FilePath("/");
kinaba 2014/04/30 07:55:03 FilePath::FromUTF8Unsafe or FILE_PATH_LITERAL("/")
mtomasz 2014/04/30 09:18:24 Done.
84 for (size_t i = 1; i < components.size(); ++i) { 89 for (size_t i = 1; i < components.size(); ++i) {
85 // TODO(mtomasz): This could be optimized, to avoid unnecessary copies. 90 // TODO(mtomasz): This could be optimized, to avoid unnecessary copies.
86 file_path_ = file_path_.Append(components[i]); 91 file_path_ = file_path_.Append(components[i]);
87 } 92 }
88 93
89 return true; 94 return true;
90 } 95 }
91 96
92 // Nothing has been found. 97 // Nothing has been found.
93 return false; 98 return false;
94 } 99 }
95 100
96 } // namespace util 101 } // namespace util
97 } // namespace file_system_provider 102 } // namespace file_system_provider
98 } // namespace chromeos 103 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698