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

Side by Side Diff: base/android/library_loader/library_prefetcher.cc

Issue 1325053009: cygprofile: increase timeouts to allow showing web contents (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 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 | build/common.gypi » ('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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "base/android/library_loader/library_prefetcher.h" 5 #include "base/android/library_loader/library_prefetcher.h"
6 6
7 #include <sys/resource.h> 7 #include <sys/resource.h>
8 #include <sys/wait.h> 8 #include <sys/wait.h>
9 #include <unistd.h> 9 #include <unistd.h>
10 #include <utility> 10 #include <utility>
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 regions_to_prefetch.push_back(region); 111 regions_to_prefetch.push_back(region);
112 } 112 }
113 } 113 }
114 114
115 FilterLibchromeRangesOnlyIfPossible(regions_to_prefetch, ranges); 115 FilterLibchromeRangesOnlyIfPossible(regions_to_prefetch, ranges);
116 return true; 116 return true;
117 } 117 }
118 118
119 // static 119 // static
120 bool NativeLibraryPrefetcher::ForkAndPrefetchNativeLibrary() { 120 bool NativeLibraryPrefetcher::ForkAndPrefetchNativeLibrary() {
121 // Avoid forking with cygprofile instrumentation because the latter performs
122 // memory allocations.
123 #if defined(CYGPROFILE_INSTRUMENTATION)
124 return false;
125 #endif
126
121 // Looking for ranges is done before the fork, to avoid syscalls and/or memory 127 // Looking for ranges is done before the fork, to avoid syscalls and/or memory
122 // allocations in the forked process. The child process inherits the lock 128 // allocations in the forked process. The child process inherits the lock
123 // state of its parent thread. It cannot rely on being able to acquire any 129 // state of its parent thread. It cannot rely on being able to acquire any
124 // lock (unless special care is taken in a pre-fork handler), including being 130 // lock (unless special care is taken in a pre-fork handler), including being
125 // able to call malloc(). 131 // able to call malloc().
126 std::vector<AddressRange> ranges; 132 std::vector<AddressRange> ranges;
127 if (!FindRanges(&ranges)) 133 if (!FindRanges(&ranges))
128 return false; 134 return false;
135
129 pid_t pid = fork(); 136 pid_t pid = fork();
130 if (pid == 0) { 137 if (pid == 0) {
131 setpriority(PRIO_PROCESS, 0, kBackgroundPriority); 138 setpriority(PRIO_PROCESS, 0, kBackgroundPriority);
132 // _exit() doesn't call the atexit() handlers. 139 // _exit() doesn't call the atexit() handlers.
133 _exit(Prefetch(ranges) ? 0 : 1); 140 _exit(Prefetch(ranges) ? 0 : 1);
134 } else { 141 } else {
135 if (pid < 0) { 142 if (pid < 0) {
136 return false; 143 return false;
137 } 144 }
138 int status; 145 int status;
139 const pid_t result = HANDLE_EINTR(waitpid(pid, &status, 0)); 146 const pid_t result = HANDLE_EINTR(waitpid(pid, &status, 0));
140 if (result == pid) { 147 if (result == pid) {
141 if (WIFEXITED(status)) { 148 if (WIFEXITED(status)) {
142 return WEXITSTATUS(status) == 0; 149 return WEXITSTATUS(status) == 0;
143 } 150 }
144 } 151 }
145 return false; 152 return false;
146 } 153 }
147 } 154 }
148 155
149 } // namespace android 156 } // namespace android
150 } // namespace base 157 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | build/common.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698