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

Side by Side Diff: chrome/browser/chromeos/file_manager/fileapi_util.cc

Issue 242443004: Remove thread restriction of fileapi::FileSystemContext::ResolveURL. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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
« no previous file with comments | « no previous file | webkit/browser/fileapi/file_system_context.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 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_manager/fileapi_util.h" 5 #include "chrome/browser/chromeos/file_manager/fileapi_util.h"
6 6
7 #include "base/files/file.h" 7 #include "base/files/file.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "chrome/browser/chromeos/drive/file_system_util.h" 9 #include "chrome/browser/chromeos/drive/file_system_util.h"
10 #include "chrome/browser/extensions/extension_util.h" 10 #include "chrome/browser/extensions/extension_util.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 // Converts the element under the iterator to an entry. First, converts 64 // Converts the element under the iterator to an entry. First, converts
65 // the virtual path to an URL, and calls OnResolvedURL(). In case of error 65 // the virtual path to an URL, and calls OnResolvedURL(). In case of error
66 // calls OnIteratorConverted with an error entry definition. 66 // calls OnIteratorConverted with an error entry definition.
67 void ConvertNextIterator(scoped_ptr<FileDefinitionListConverter> self_deleter, 67 void ConvertNextIterator(scoped_ptr<FileDefinitionListConverter> self_deleter,
68 FileDefinitionList::const_iterator iterator); 68 FileDefinitionList::const_iterator iterator);
69 69
70 // Creates an entry definition from the URL as well as the file definition. 70 // Creates an entry definition from the URL as well as the file definition.
71 // Then, calls OnIteratorConverted with the created entry definition. 71 // Then, calls OnIteratorConverted with the created entry definition.
72 void OnResolvedURL(scoped_ptr<FileDefinitionListConverter> self_deleter, 72 void OnResolvedURL(scoped_ptr<FileDefinitionListConverter> self_deleter,
73 FileDefinitionList::const_iterator iterator, 73 FileDefinitionList::const_iterator iterator,
74 const GURL& root_url, 74 base::File::Error error,
75 const std::string& name, 75 const fileapi::FileSystemInfo& info,
76 base::File::Error error); 76 const base::FilePath& file_path,
77 bool is_directory);
77 78
78 // Called when the iterator is converted. Adds the |entry_definition| to 79 // Called when the iterator is converted. Adds the |entry_definition| to
79 // |results_| and calls ConvertNextIterator() for the next element. 80 // |results_| and calls ConvertNextIterator() for the next element.
80 void OnIteratorConverted(scoped_ptr<FileDefinitionListConverter> self_deleter, 81 void OnIteratorConverted(scoped_ptr<FileDefinitionListConverter> self_deleter,
81 FileDefinitionList::const_iterator iterator, 82 FileDefinitionList::const_iterator iterator,
82 const EntryDefinition& entry_definition); 83 const EntryDefinition& entry_definition);
83 84
84 scoped_refptr<fileapi::FileSystemContext> file_system_context_; 85 scoped_refptr<fileapi::FileSystemContext> file_system_context_;
85 const std::string extension_id_; 86 const std::string extension_id_;
86 const FileDefinitionList file_definition_list_; 87 const FileDefinitionList file_definition_list_;
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 } 134 }
134 135
135 fileapi::ExternalFileSystemBackend* backend = 136 fileapi::ExternalFileSystemBackend* backend =
136 file_system_context_->external_backend(); 137 file_system_context_->external_backend();
137 if (!backend) { 138 if (!backend) {
138 OnIteratorConverted(self_deleter.Pass(), 139 OnIteratorConverted(self_deleter.Pass(),
139 iterator, 140 iterator,
140 CreateEntryDefinitionWithError( 141 CreateEntryDefinitionWithError(
141 base::File::FILE_ERROR_INVALID_OPERATION)); 142 base::File::FILE_ERROR_INVALID_OPERATION));
142 return; 143 return;
143 } 144 }
kinuko 2014/04/18 07:35:02 Looks like this code will no longer be necessary
kinaba 2014/04/21 04:51:41 Done.
144 145
145 fileapi::FileSystemURL url = file_system_context_->CreateCrackedFileSystemURL( 146 fileapi::FileSystemURL url = file_system_context_->CreateCrackedFileSystemURL(
146 extensions::Extension::GetBaseURLFromExtensionId(extension_id_), 147 extensions::Extension::GetBaseURLFromExtensionId(extension_id_),
147 fileapi::kFileSystemTypeExternal, 148 fileapi::kFileSystemTypeExternal,
148 iterator->virtual_path); 149 iterator->virtual_path);
149 DCHECK(url.is_valid()); 150 DCHECK(url.is_valid());
150 151
151 // The converter object will be deleted if the callback is not called because 152 // The converter object will be deleted if the callback is not called because
152 // of shutdown during ResolveURL(). 153 // of shutdown during ResolveURL().
153 // 154 file_system_context_->ResolveURL(
154 // TODO(mtomasz, nhiroki): Call FileSystemContext::ResolveURL() directly,
155 // after removing redundant thread restrictions in there.
156 backend->ResolveURL(
157 url, 155 url,
158 // Not sandboxed file systems are not creatable via ResolveURL().
159 fileapi::OPEN_FILE_SYSTEM_FAIL_IF_NONEXISTENT,
160 base::Bind(&FileDefinitionListConverter::OnResolvedURL, 156 base::Bind(&FileDefinitionListConverter::OnResolvedURL,
161 base::Unretained(this), 157 base::Unretained(this),
162 base::Passed(&self_deleter), 158 base::Passed(&self_deleter),
163 iterator)); 159 iterator));
164 } 160 }
165 161
166 void FileDefinitionListConverter::OnResolvedURL( 162 void FileDefinitionListConverter::OnResolvedURL(
167 scoped_ptr<FileDefinitionListConverter> self_deleter, 163 scoped_ptr<FileDefinitionListConverter> self_deleter,
168 FileDefinitionList::const_iterator iterator, 164 FileDefinitionList::const_iterator iterator,
169 const GURL& root_url, 165 base::File::Error error,
170 const std::string& name, 166 const fileapi::FileSystemInfo& info,
171 base::File::Error error) { 167 const base::FilePath& file_path,
168 bool is_directory) {
172 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 169 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
173 170
174 EntryDefinition entry_definition; 171 EntryDefinition entry_definition;
175 entry_definition.file_system_root_url = root_url.spec(); 172 entry_definition.file_system_root_url = info.root_url.spec();
176 entry_definition.file_system_name = name; 173 entry_definition.file_system_name = info.name;
177 entry_definition.is_directory = iterator->is_directory; 174 entry_definition.is_directory = is_directory;
178 entry_definition.error = error; 175 entry_definition.error = error;
179 176
180 // Construct a target Entry.fullPath value from the virtual path and the 177 // Construct a target Entry.fullPath value from the virtual path and the
181 // root URL. Eg. Downloads/A/b.txt -> A/b.txt. 178 // root URL. Eg. Downloads/A/b.txt -> A/b.txt.
182 const base::FilePath root_virtual_path = 179 const base::FilePath root_virtual_path =
183 file_system_context_->CrackURL(root_url).virtual_path(); 180 file_system_context_->CrackURL(info.root_url).virtual_path();
184 DCHECK(root_virtual_path == iterator->virtual_path || 181 DCHECK(root_virtual_path == iterator->virtual_path ||
185 root_virtual_path.IsParent(iterator->virtual_path)); 182 root_virtual_path.IsParent(iterator->virtual_path));
mtomasz 2014/04/18 07:00:11 FYI, this fails in tests.
186 base::FilePath full_path; 183 base::FilePath full_path;
187 root_virtual_path.AppendRelativePath(iterator->virtual_path, &full_path); 184 root_virtual_path.AppendRelativePath(iterator->virtual_path, &full_path);
188 entry_definition.full_path = full_path; 185 entry_definition.full_path = full_path;
189 186
190 OnIteratorConverted(self_deleter.Pass(), iterator, entry_definition); 187 OnIteratorConverted(self_deleter.Pass(), iterator, entry_definition);
191 } 188 }
192 189
193 void FileDefinitionListConverter::OnIteratorConverted( 190 void FileDefinitionListConverter::OnIteratorConverted(
194 scoped_ptr<FileDefinitionListConverter> self_deleter, 191 scoped_ptr<FileDefinitionListConverter> self_deleter,
195 FileDefinitionList::const_iterator iterator, 192 FileDefinitionList::const_iterator iterator,
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 file_definition_list.push_back(file_definition); 316 file_definition_list.push_back(file_definition);
320 ConvertFileDefinitionListToEntryDefinitionList( 317 ConvertFileDefinitionListToEntryDefinitionList(
321 profile, 318 profile,
322 extension_id, 319 extension_id,
323 file_definition_list, 320 file_definition_list,
324 base::Bind(&OnConvertFileDefinitionDone, callback)); 321 base::Bind(&OnConvertFileDefinitionDone, callback));
325 } 322 }
326 323
327 } // namespace util 324 } // namespace util
328 } // namespace file_manager 325 } // namespace file_manager
OLDNEW
« no previous file with comments | « no previous file | webkit/browser/fileapi/file_system_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698