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

Side by Side Diff: components/nacl/renderer/plugin/pnacl_resources.cc

Issue 1640523002: PNaCl cleanup: Reuse base::File for closing a handle/FD (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 4 years, 11 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 | « no previous file | components/nacl/renderer/plugin/utility.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/nacl/renderer/plugin/pnacl_resources.h" 5 #include "components/nacl/renderer/plugin/pnacl_resources.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/files/file.h"
11 #include "base/logging.h" 12 #include "base/logging.h"
12 #include "components/nacl/renderer/plugin/plugin.h" 13 #include "components/nacl/renderer/plugin/plugin.h"
13 #include "components/nacl/renderer/plugin/utility.h" 14 #include "components/nacl/renderer/plugin/utility.h"
14 #include "ppapi/c/pp_errors.h" 15 #include "ppapi/c/pp_errors.h"
15 16
16 namespace plugin { 17 namespace plugin {
17 18
18 namespace { 19 namespace {
19 20
20 static const char kPnaclBaseUrl[] = "chrome://pnacl-translator/"; 21 static const char kPnaclBaseUrl[] = "chrome://pnacl-translator/";
21 22
22 std::string GetFullUrl(const std::string& partial_url) { 23 std::string GetFullUrl(const std::string& partial_url) {
23 return std::string(kPnaclBaseUrl) + GetNaClInterface()->GetSandboxArch() + 24 return std::string(kPnaclBaseUrl) + GetNaClInterface()->GetSandboxArch() +
24 "/" + partial_url; 25 "/" + partial_url;
25 } 26 }
26 27
27 } // namespace 28 } // namespace
28 29
29 PnaclResources::PnaclResources(Plugin* plugin, bool use_subzero) 30 PnaclResources::PnaclResources(Plugin* plugin, bool use_subzero)
30 : plugin_(plugin), use_subzero_(use_subzero) { 31 : plugin_(plugin), use_subzero_(use_subzero) {
31 for (PnaclResourceEntry& entry : resources_) { 32 for (PnaclResourceEntry& entry : resources_) {
32 entry.file_info = kInvalidNaClFileInfo; 33 entry.file_info = kInvalidNaClFileInfo;
33 } 34 }
34 } 35 }
35 36
36 PnaclResources::~PnaclResources() { 37 PnaclResources::~PnaclResources() {
37 for (PnaclResourceEntry& entry : resources_) { 38 for (PnaclResourceEntry& entry : resources_) {
38 if (entry.file_info.handle != PP_kInvalidFileHandle) 39 base::File closer(entry.file_info.handle);
39 CloseFileHandle(entry.file_info.handle);
40 } 40 }
41 } 41 }
42 42
43 const std::string& PnaclResources::GetUrl(ResourceType type) const { 43 const std::string& PnaclResources::GetUrl(ResourceType type) const {
44 size_t index = static_cast<size_t>(type); 44 size_t index = static_cast<size_t>(type);
45 DCHECK(index < NUM_TYPES); 45 DCHECK(index < NUM_TYPES);
46 return resources_[index].tool_name; 46 return resources_[index].tool_name;
47 } 47 }
48 48
49 PP_NaClFileInfo PnaclResources::TakeFileInfo(ResourceType type) { 49 PP_NaClFileInfo PnaclResources::TakeFileInfo(ResourceType type) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 for (ResourceType t : to_load) { 91 for (ResourceType t : to_load) {
92 plugin_->nacl_interface()->GetReadExecPnaclFd( 92 plugin_->nacl_interface()->GetReadExecPnaclFd(
93 resources_[t].tool_name.c_str(), &resources_[t].file_info); 93 resources_[t].tool_name.c_str(), &resources_[t].file_info);
94 all_valid = 94 all_valid =
95 all_valid && resources_[t].file_info.handle != PP_kInvalidFileHandle; 95 all_valid && resources_[t].file_info.handle != PP_kInvalidFileHandle;
96 } 96 }
97 return all_valid; 97 return all_valid;
98 } 98 }
99 99
100 } // namespace plugin 100 } // namespace plugin
OLDNEW
« no previous file with comments | « no previous file | components/nacl/renderer/plugin/utility.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698