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

Side by Side Diff: components/nacl/browser/nacl_browser.cc

Issue 728113002: obsolete: SFI NaCl: Batch-open resource files (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address comments Created 6 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 | « components/nacl/browser/nacl_browser.h ('k') | components/nacl/browser/nacl_process_host.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 "components/nacl/browser/nacl_browser.h" 5 #include "components/nacl/browser/nacl_browser.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_proxy.h" 8 #include "base/files/file_proxy.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 // Check that the file does not reference a directory. Returning a descriptor 129 // Check that the file does not reference a directory. Returning a descriptor
130 // to an extension directory could allow an outer sandbox escape. openat(...) 130 // to an extension directory could allow an outer sandbox escape. openat(...)
131 // could be used to traverse into the file system. 131 // could be used to traverse into the file system.
132 base::File::Info file_info; 132 base::File::Info file_info;
133 if (!file.GetInfo(&file_info) || file_info.is_directory) 133 if (!file.GetInfo(&file_info) || file_info.is_directory)
134 return base::File(); 134 return base::File();
135 135
136 return file.Pass(); 136 return file.Pass();
137 } 137 }
138 138
139 OpenNaClFileReadExecImplResult::OpenNaClFileReadExecImplResult() {
140 }
141
142 OpenNaClFileReadExecImplResult::OpenNaClFileReadExecImplResult(
143 base::File file,
144 base::FilePath file_path)
145 : file_(file.Pass()),
146 file_path_(file_path) {
147 }
148
149 OpenNaClFileReadExecImplResult::~OpenNaClFileReadExecImplResult() {
150 }
151
152 OpenNaClFileReadExecImplResult::OpenNaClFileReadExecImplResult(RValue other)
153 : file_(other.object->file_.Pass()),
154 file_path_(other.object->file_path()) {
155 }
156
157 OpenNaClFileReadExecImplResult&
158 OpenNaClFileReadExecImplResult::operator=(RValue other) {
159 if (this != other.object) {
160 file_ = other.object->file_.Pass();
161 file_path_ = other.object->file_path();
162 }
163 return *this;
164 }
165
166 bool OpenNaClFileReadExecImplResult::IsValid() const {
167 return file_.IsValid();
168 }
169
170 scoped_ptr<OpenNaClFileReadExecImplResult[]> OpenNaClFilesReadExecImpl(
171 const std::vector<base::FilePath>& file_paths, bool is_executable) {
172 DCHECK(!file_paths.empty());
173 scoped_ptr<OpenNaClFileReadExecImplResult[]> result(
174 new OpenNaClFileReadExecImplResult[file_paths.size()]);
175 for (size_t i = 0; i < file_paths.size(); ++i) {
176 result[i] = OpenNaClFileReadExecImplResult(
177 OpenNaClReadExecImpl(file_paths[i], is_executable).Pass(),
178 file_paths[i]).Pass();
179 }
180 return result.Pass();
181 }
182
139 NaClBrowser::NaClBrowser() 183 NaClBrowser::NaClBrowser()
140 : irt_filepath_(), 184 : irt_filepath_(),
141 irt_state_(NaClResourceUninitialized), 185 irt_state_(NaClResourceUninitialized),
142 validation_cache_file_path_(), 186 validation_cache_file_path_(),
143 validation_cache_is_enabled_( 187 validation_cache_is_enabled_(
144 CheckEnvVar("NACL_VALIDATION_CACHE", 188 CheckEnvVar("NACL_VALIDATION_CACHE",
145 kValidationCacheEnabledByDefault)), 189 kValidationCacheEnabledByDefault)),
146 validation_cache_is_modified_(false), 190 validation_cache_is_modified_(false),
147 validation_cache_state_(NaClResourceUninitialized), 191 validation_cache_state_(NaClResourceUninitialized),
148 path_cache_(kFilePathCacheSize), 192 path_cache_(kFilePathCacheSize),
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 bool NaClBrowser::IsThrottled() { 599 bool NaClBrowser::IsThrottled() {
556 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 600 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
557 if (crash_times_.size() != kMaxCrashesPerInterval) { 601 if (crash_times_.size() != kMaxCrashesPerInterval) {
558 return false; 602 return false;
559 } 603 }
560 base::TimeDelta delta = base::Time::Now() - crash_times_.front(); 604 base::TimeDelta delta = base::Time::Now() - crash_times_.front();
561 return delta.InSeconds() <= kCrashesIntervalInSeconds; 605 return delta.InSeconds() <= kCrashesIntervalInSeconds;
562 } 606 }
563 607
564 } // namespace nacl 608 } // namespace nacl
OLDNEW
« no previous file with comments | « components/nacl/browser/nacl_browser.h ('k') | components/nacl/browser/nacl_process_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698