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

Side by Side Diff: services/catalog/public/cpp/resource_loader.cc

Issue 1962503002: Add mojom module suffix in .mojom files for components/filesystem. (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
« no previous file with comments | « services/catalog/public/cpp/resource_loader.h ('k') | services/shell/shell.cc » ('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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "services/catalog/public/cpp/resource_loader.h" 5 #include "services/catalog/public/cpp/resource_loader.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 10 matching lines...) Expand all
21 MojoPlatformHandle platform_handle; 21 MojoPlatformHandle platform_handle;
22 CHECK(MojoExtractPlatformHandle(handle.release().value(), 22 CHECK(MojoExtractPlatformHandle(handle.release().value(),
23 &platform_handle) == MOJO_RESULT_OK); 23 &platform_handle) == MOJO_RESULT_OK);
24 return base::File(platform_handle); 24 return base::File(platform_handle);
25 } 25 }
26 } 26 }
27 27
28 ResourceLoader::ResourceLoader() {} 28 ResourceLoader::ResourceLoader() {}
29 ResourceLoader::~ResourceLoader() {} 29 ResourceLoader::~ResourceLoader() {}
30 30
31 bool ResourceLoader::OpenFiles(filesystem::DirectoryPtr directory, 31 bool ResourceLoader::OpenFiles(filesystem::mojom::DirectoryPtr directory,
32 const std::set<std::string>& paths) { 32 const std::set<std::string>& paths) {
33 mojo::Array<filesystem::FileOpenDetailsPtr> details( 33 mojo::Array<filesystem::mojom::FileOpenDetailsPtr> details(
34 mojo::Array<filesystem::FileOpenDetailsPtr>::New(paths.size())); 34 mojo::Array<filesystem::mojom::FileOpenDetailsPtr>::New(paths.size()));
35 size_t i = 0; 35 size_t i = 0;
36 for (const auto& path : paths) { 36 for (const auto& path : paths) {
37 filesystem::FileOpenDetailsPtr open_details( 37 filesystem::mojom::FileOpenDetailsPtr open_details(
38 filesystem::FileOpenDetails::New()); 38 filesystem::mojom::FileOpenDetails::New());
39 open_details->path = path; 39 open_details->path = path;
40 open_details->open_flags = filesystem::kFlagOpen | filesystem::kFlagRead; 40 open_details->open_flags =
41 filesystem::mojom::kFlagOpen | filesystem::mojom::kFlagRead;
41 details[i++] = std::move(open_details); 42 details[i++] = std::move(open_details);
42 } 43 }
43 44
44 mojo::Array<filesystem::FileOpenResultPtr> results( 45 mojo::Array<filesystem::mojom::FileOpenResultPtr> results(
45 mojo::Array<filesystem::FileOpenResultPtr>::New(paths.size())); 46 mojo::Array<filesystem::mojom::FileOpenResultPtr>::New(paths.size()));
46 if (!directory->OpenFileHandles(std::move(details), &results)) 47 if (!directory->OpenFileHandles(std::move(details), &results))
47 return false; 48 return false;
48 49
49 for (const auto& result : results) { 50 for (const auto& result : results) {
50 resource_map_[result->path].reset( 51 resource_map_[result->path].reset(
51 new base::File(GetFileFromHandle(std::move(result->file_handle)))); 52 new base::File(GetFileFromHandle(std::move(result->file_handle))));
52 } 53 }
53 return true; 54 return true;
54 } 55 }
55 56
56 base::File ResourceLoader::TakeFile(const std::string& path) { 57 base::File ResourceLoader::TakeFile(const std::string& path) {
57 std::unique_ptr<base::File> file_wrapper(std::move(resource_map_[path])); 58 std::unique_ptr<base::File> file_wrapper(std::move(resource_map_[path]));
58 resource_map_.erase(path); 59 resource_map_.erase(path);
59 return std::move(*file_wrapper); 60 return std::move(*file_wrapper);
60 } 61 }
61 62
62 } // namespace catalog 63 } // namespace catalog
OLDNEW
« no previous file with comments | « services/catalog/public/cpp/resource_loader.h ('k') | services/shell/shell.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698