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

Side by Side Diff: components/crash/content/app/run_as_crashpad_handler_win.cc

Issue 2674253003: Populate allocation size into OOM exception on Windows. (Closed)
Patch Set: Created 3 years, 10 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
« base/process/memory_win.cc ('K') | « base/process/memory_win.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 "components/crash/content/app/run_as_crashpad_handler_win.h" 5 #include "components/crash/content/app/run_as_crashpad_handler_win.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/process/memory.h"
13 #include "base/strings/string16.h" 14 #include "base/strings/string16.h"
14 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
15 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
16 #include "third_party/crashpad/crashpad/handler/handler_main.h" 17 #include "third_party/crashpad/crashpad/handler/handler_main.h"
17 18
18 namespace crash_reporter { 19 namespace crash_reporter {
19 20
20 int RunAsCrashpadHandler(const base::CommandLine& command_line) { 21 int RunAsCrashpadHandler(const base::CommandLine& command_line) {
22 // Make sure this process terminates on OOM in the same mode as other Chrome
23 // processes.
24 base::EnableTerminationOnOutOfMemory();
Mark Mentovai 2017/02/06 18:22:39 We should centralize all of the Chrome-specific cr
Sigurður Ásgeirsson 2017/02/06 19:43:58 I felt it was clearer to have the SetupFallbackCra
25
21 std::vector<base::string16> argv = command_line.argv(); 26 std::vector<base::string16> argv = command_line.argv();
22 const base::string16 process_type = L"--type="; 27 const base::string16 process_type = L"--type=";
23 argv.erase(std::remove_if(argv.begin(), argv.end(), 28 argv.erase(std::remove_if(argv.begin(), argv.end(),
24 [&process_type](const base::string16& str) { 29 [&process_type](const base::string16& str) {
25 return base::StartsWith( 30 return base::StartsWith(
26 str, process_type, 31 str, process_type,
27 base::CompareCase::SENSITIVE) || 32 base::CompareCase::SENSITIVE) ||
28 (!str.empty() && str[0] == L'/'); 33 (!str.empty() && str[0] == L'/');
29 }), 34 }),
30 argv.end()); 35 argv.end());
31 36
32 std::unique_ptr<char* []> argv_as_utf8(new char*[argv.size() + 1]); 37 std::unique_ptr<char* []> argv_as_utf8(new char*[argv.size() + 1]);
33 std::vector<std::string> storage; 38 std::vector<std::string> storage;
34 storage.reserve(argv.size()); 39 storage.reserve(argv.size());
35 for (size_t i = 0; i < argv.size(); ++i) { 40 for (size_t i = 0; i < argv.size(); ++i) {
36 storage.push_back(base::UTF16ToUTF8(argv[i])); 41 storage.push_back(base::UTF16ToUTF8(argv[i]));
37 argv_as_utf8[i] = &storage[i][0]; 42 argv_as_utf8[i] = &storage[i][0];
38 } 43 }
39 argv_as_utf8[argv.size()] = nullptr; 44 argv_as_utf8[argv.size()] = nullptr;
40 argv.clear(); 45 argv.clear();
41 return crashpad::HandlerMain(static_cast<int>(storage.size()), 46 return crashpad::HandlerMain(static_cast<int>(storage.size()),
42 argv_as_utf8.get()); 47 argv_as_utf8.get());
43 } 48 }
44 49
45 } // namespace crash_reporter 50 } // namespace crash_reporter
OLDNEW
« base/process/memory_win.cc ('K') | « base/process/memory_win.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698