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

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

Issue 2492283002: Mojo C++ bindings: switch components/filesystem mojom target to use STL types. (Closed)
Patch Set: Created 4 years, 1 month 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 | « content/browser/dom_storage/dom_storage_context_wrapper.cc ('k') | no next file » | 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 15 matching lines...) Expand all
26 return base::File(platform_file); 26 return base::File(platform_file);
27 } 27 }
28 28
29 } // namespace 29 } // namespace
30 30
31 ResourceLoader::ResourceLoader() {} 31 ResourceLoader::ResourceLoader() {}
32 ResourceLoader::~ResourceLoader() {} 32 ResourceLoader::~ResourceLoader() {}
33 33
34 bool ResourceLoader::OpenFiles(filesystem::mojom::DirectoryPtr directory, 34 bool ResourceLoader::OpenFiles(filesystem::mojom::DirectoryPtr directory,
35 const std::set<std::string>& paths) { 35 const std::set<std::string>& paths) {
36 mojo::Array<filesystem::mojom::FileOpenDetailsPtr> details( 36 std::vector<filesystem::mojom::FileOpenDetailsPtr> details(paths.size());
37 mojo::Array<filesystem::mojom::FileOpenDetailsPtr>::New(paths.size()));
38 size_t i = 0; 37 size_t i = 0;
39 for (const auto& path : paths) { 38 for (const auto& path : paths) {
40 filesystem::mojom::FileOpenDetailsPtr open_details( 39 filesystem::mojom::FileOpenDetailsPtr open_details(
41 filesystem::mojom::FileOpenDetails::New()); 40 filesystem::mojom::FileOpenDetails::New());
42 open_details->path = path; 41 open_details->path = path;
43 open_details->open_flags = 42 open_details->open_flags =
44 filesystem::mojom::kFlagOpen | filesystem::mojom::kFlagRead; 43 filesystem::mojom::kFlagOpen | filesystem::mojom::kFlagRead;
45 details[i++] = std::move(open_details); 44 details[i++] = std::move(open_details);
46 } 45 }
47 46
48 mojo::Array<filesystem::mojom::FileOpenResultPtr> results( 47 std::vector<filesystem::mojom::FileOpenResultPtr> results;
49 mojo::Array<filesystem::mojom::FileOpenResultPtr>::New(paths.size()));
50 if (!directory->OpenFileHandles(std::move(details), &results)) 48 if (!directory->OpenFileHandles(std::move(details), &results))
51 return false; 49 return false;
52 50
53 for (const auto& result : results) { 51 for (const auto& result : results) {
54 resource_map_[result->path].reset( 52 resource_map_[result->path].reset(
55 new base::File(GetFileFromHandle(std::move(result->file_handle)))); 53 new base::File(GetFileFromHandle(std::move(result->file_handle))));
56 } 54 }
57 return true; 55 return true;
58 } 56 }
59 57
60 base::File ResourceLoader::TakeFile(const std::string& path) { 58 base::File ResourceLoader::TakeFile(const std::string& path) {
61 std::unique_ptr<base::File> file_wrapper(std::move(resource_map_[path])); 59 std::unique_ptr<base::File> file_wrapper(std::move(resource_map_[path]));
62 resource_map_.erase(path); 60 resource_map_.erase(path);
63 return std::move(*file_wrapper); 61 return std::move(*file_wrapper);
64 } 62 }
65 63
66 } // namespace catalog 64 } // namespace catalog
OLDNEW
« no previous file with comments | « content/browser/dom_storage/dom_storage_context_wrapper.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698