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

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

Issue 224803002: Enable mmap and identity-based validation caching on pnacl-{llc,ld}.nexe (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix token handover for main nexe Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « components/nacl/browser/nacl_browser.h ('k') | components/nacl/browser/nacl_file_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/file_util.h" 8 #include "base/file_util.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 } 109 }
110 110
111 // Crash throttling parameters. 111 // Crash throttling parameters.
112 const size_t kMaxCrashesPerInterval = 3; 112 const size_t kMaxCrashesPerInterval = 3;
113 const int64 kCrashesIntervalInSeconds = 120; 113 const int64 kCrashesIntervalInSeconds = 120;
114 114
115 } // namespace 115 } // namespace
116 116
117 namespace nacl { 117 namespace nacl {
118 118
119 base::File OpenNaClExecutableImpl(const base::FilePath& file_path) { 119 base::File OpenNaClReadExecImpl(const base::FilePath& file_path,
120 bool is_executable) {
120 // Get a file descriptor. On Windows, we need 'GENERIC_EXECUTE' in order to 121 // Get a file descriptor. On Windows, we need 'GENERIC_EXECUTE' in order to
121 // memory map the executable. 122 // memory map the executable.
122 // IMPORTANT: This file descriptor must not have write access - that could 123 // IMPORTANT: This file descriptor must not have write access - that could
123 // allow a NaCl inner sandbox escape. 124 // allow a NaCl inner sandbox escape.
124 base::File file(file_path, 125
125 (base::File::FLAG_OPEN | 126 base::File file(file_path, is_executable
126 base::File::FLAG_READ | 127 ? base::File::FLAG_OPEN |
127 base::File::FLAG_EXECUTE)); // Windows only flag. 128 base::File::FLAG_READ |
129 base::File::FLAG_EXECUTE // Windows only flag
130 : base::File::FLAG_OPEN |
131 base::File::FLAG_READ);
128 if (!file.IsValid()) 132 if (!file.IsValid())
129 return file.Pass(); 133 return file.Pass();
130 134
131 // Check that the file does not reference a directory. Returning a descriptor 135 // Check that the file does not reference a directory. Returning a descriptor
132 // to an extension directory could allow an outer sandbox escape. openat(...) 136 // to a directory could allow an outer sandbox escape. openat(...)
133 // could be used to traverse into the file system. 137 // could be used to traverse into the file system.
134 base::File::Info file_info; 138 base::File::Info file_info;
135 if (!file.GetInfo(&file_info) || file_info.is_directory) 139 if (!file.GetInfo(&file_info) || file_info.is_directory)
136 return base::File(); 140 return base::File();
137 141
138 return file.Pass(); 142 return file.Pass();
139 } 143 }
140 144
141 NaClBrowser::NaClBrowser() 145 NaClBrowser::NaClBrowser()
142 : weak_factory_(this), 146 : weak_factory_(this),
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 bool NaClBrowser::IsThrottled() { 553 bool NaClBrowser::IsThrottled() {
550 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); 554 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO));
551 if (crash_times_.size() != kMaxCrashesPerInterval) { 555 if (crash_times_.size() != kMaxCrashesPerInterval) {
552 return false; 556 return false;
553 } 557 }
554 base::TimeDelta delta = base::Time::Now() - crash_times_.front(); 558 base::TimeDelta delta = base::Time::Now() - crash_times_.front();
555 return delta.InSeconds() <= kCrashesIntervalInSeconds; 559 return delta.InSeconds() <= kCrashesIntervalInSeconds;
556 } 560 }
557 561
558 } // namespace nacl 562 } // namespace nacl
OLDNEW
« no previous file with comments | « components/nacl/browser/nacl_browser.h ('k') | components/nacl/browser/nacl_file_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698