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

Side by Side Diff: components/filesystem/directory_impl.cc

Issue 1942473002: Eliminate mojo:resource_provider (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 4 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/filesystem/directory_impl.h" 5 #include "components/filesystem/directory_impl.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/files/file.h" 9 #include "base/files/file.h"
10 #include "base/files/file_enumerator.h" 10 #include "base/files/file_enumerator.h"
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 MojoResult create_result = MojoCreatePlatformHandleWrapper( 116 MojoResult create_result = MojoCreatePlatformHandleWrapper(
117 base_file.TakePlatformFile(), &mojo_handle); 117 base_file.TakePlatformFile(), &mojo_handle);
118 if (create_result != MOJO_RESULT_OK) { 118 if (create_result != MOJO_RESULT_OK) {
119 callback.Run(FileError::FAILED, ScopedHandle()); 119 callback.Run(FileError::FAILED, ScopedHandle());
120 return; 120 return;
121 } 121 }
122 122
123 callback.Run(FileError::OK, ScopedHandle(mojo::Handle(mojo_handle))); 123 callback.Run(FileError::OK, ScopedHandle(mojo::Handle(mojo_handle)));
124 } 124 }
125 125
126 void DirectoryImpl::OpenFileHandles(mojo::Array<FileOpenDetailsPtr> details,
127 const OpenFileHandlesCallback& callback) {
128 /*
129 mojo::Array<FileOpenResultPtr> results(
130 mojo::Array<FileOpenResultPtr>::New(details.size()));
131 size_t i = 0;
132 for (const auto& detail : details) {
133 FileOpenResultPtr result(FileOpenResult::New());
134 result->path = detail->path;
135
136 base::FilePath path;
137 FileError error = ValidatePath(detail->path, directory_path_, &path);
138 if (error != FileError::OK) {
139 result->error = error;
140 result->file_handle = ScopedHandle();
141 results[i] = std::move(result);
142 continue;
143 }
144
145 if (base::DirectoryExists(path)) {
146 // We must not return directories as files. In the file abstraction, we ca n
147 // fetch raw file descriptors over mojo pipes, and passing a file
148 // descriptor to a directory is a sandbox escape on Windows.
149 result->error = FileError::NOT_A_FILE;
150 result->file_handle = ScopedHandle();
151 results[i] = std::move(result);
152 continue;
153 }
154
155 base::File base_file(path, detail->open_flags);
156 if (!base_file.IsValid()) {
157 result->error = GetError(base_file);
158 result->file_handle = ScopedHandle();
159 results[i] = std::move(result);
160 continue;
161 }
162
163 MojoHandle mojo_handle;
164 MojoResult create_result = MojoCreatePlatformHandleWrapper(
165 base_file.TakePlatformFile(), &mojo_handle);
166 if (create_result != MOJO_RESULT_OK) {
167 result->error = FileError::FAILED;
168 result->file_handle = ScopedHandle();
169 results[i] = std::move(result);
170 continue;
171 }
172
173 result->error = FileError::OK;
174 result->file_handle = ScopedHandle(mojo::Handle(mojo_handle));
175 results[i] = std::move(result);
176 }
177 callback.Run(std::move(results));
178 */
179 callback.Run();
180 }
181
126 void DirectoryImpl::OpenDirectory(const mojo::String& raw_path, 182 void DirectoryImpl::OpenDirectory(const mojo::String& raw_path,
127 mojo::InterfaceRequest<Directory> directory, 183 mojo::InterfaceRequest<Directory> directory,
128 uint32_t open_flags, 184 uint32_t open_flags,
129 const OpenDirectoryCallback& callback) { 185 const OpenDirectoryCallback& callback) {
130 base::FilePath path; 186 base::FilePath path;
131 FileError error = ValidatePath(raw_path, directory_path_, &path); 187 FileError error = ValidatePath(raw_path, directory_path_, &path);
132 if (error != FileError::OK) { 188 if (error != FileError::OK) {
133 callback.Run(error); 189 callback.Run(error);
134 return; 190 return;
135 } 191 }
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 data_size) == -1) { 389 data_size) == -1) {
334 callback.Run(GetError(base_file)); 390 callback.Run(GetError(base_file));
335 return; 391 return;
336 } 392 }
337 } 393 }
338 394
339 callback.Run(FileError::OK); 395 callback.Run(FileError::OK);
340 } 396 }
341 397
342 } // namespace filesystem 398 } // namespace filesystem
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698