Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 "chrome/app/breakpad_win.h" | 5 #include "chrome/app/breakpad_win.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <shellapi.h> | 8 #include <shellapi.h> |
| 9 #include <tchar.h> | 9 #include <tchar.h> |
| 10 | 10 |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 144 | 144 |
| 145 // These surround the flags that were added by about:flags, it lets | 145 // These surround the flags that were added by about:flags, it lets |
| 146 // you distinguish which flags were added manually via the command | 146 // you distinguish which flags were added manually via the command |
| 147 // line versus those added through about:flags. For the most part | 147 // line versus those added through about:flags. For the most part |
| 148 // we don't care how an option was enabled, so we strip these. | 148 // we don't care how an option was enabled, so we strip these. |
| 149 // (If you need to know can always look at the PEB). | 149 // (If you need to know can always look at the PEB). |
| 150 flag == L"--flag-switches-begin" || | 150 flag == L"--flag-switches-begin" || |
| 151 flag == L"--flag-switches-end"; | 151 flag == L"--flag-switches-end"; |
| 152 } | 152 } |
| 153 | 153 |
| 154 extern "C" void __declspec(dllexport) __cdecl SetCommandLine( | 154 extern "C" void __declspec(dllexport) __cdecl SetCommandLine2( |
|
Sigurður Ásgeirsson
2012/05/23 21:30:31
Please add a comment here (and other places where
eroman
2012/05/23 21:45:13
Done.
| |
| 155 const wchar_t** argv, size_t argc) { | 155 const wchar_t** argv, size_t argc) { |
| 156 if (!g_custom_entries) | 156 if (!g_custom_entries) |
| 157 return; | 157 return; |
| 158 | 158 |
| 159 // Copy up to the kMaxSwitches arguments into the custom entries array. Skip | 159 // Copy up to the kMaxSwitches arguments into the custom entries array. Skip |
| 160 // past the first argument, as it is just the executable path. | 160 // past the first argument, as it is just the executable path. |
| 161 size_t argv_i = 1; | 161 size_t argv_i = 1; |
| 162 size_t num_added = 0; | 162 size_t num_added = 0; |
| 163 | 163 |
| 164 for (; argv_i < argc && num_added < kMaxSwitches; ++argv_i) { | 164 for (; argv_i < argc && num_added < kMaxSwitches; ++argv_i) { |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 295 // Read the id from registry. If reporting has never been enabled | 295 // Read the id from registry. If reporting has never been enabled |
| 296 // the result will be empty string. Its OK since when user enables reporting | 296 // the result will be empty string. Its OK since when user enables reporting |
| 297 // we will insert the new value at this location. | 297 // we will insert the new value at this location. |
| 298 std::wstring guid; | 298 std::wstring guid; |
| 299 GoogleUpdateSettings::GetMetricsId(&guid); | 299 GoogleUpdateSettings::GetMetricsId(&guid); |
| 300 g_client_id_offset = g_custom_entries->size(); | 300 g_client_id_offset = g_custom_entries->size(); |
| 301 g_custom_entries->push_back( | 301 g_custom_entries->push_back( |
| 302 google_breakpad::CustomInfoEntry(L"guid", guid.c_str())); | 302 google_breakpad::CustomInfoEntry(L"guid", guid.c_str())); |
| 303 | 303 |
| 304 // Add empty values for the command line switches. We will fill them with | 304 // Add empty values for the command line switches. We will fill them with |
| 305 // actual values as part of SetCommandLine(). | 305 // actual values as part of SetCommandLine2(). |
| 306 g_num_switches_offset = g_custom_entries->size(); | 306 g_num_switches_offset = g_custom_entries->size(); |
| 307 g_custom_entries->push_back( | 307 g_custom_entries->push_back( |
| 308 google_breakpad::CustomInfoEntry(L"num-switches", L"")); | 308 google_breakpad::CustomInfoEntry(L"num-switches", L"")); |
| 309 | 309 |
| 310 g_switches_offset = g_custom_entries->size(); | 310 g_switches_offset = g_custom_entries->size(); |
| 311 // one-based index for the name suffix. | 311 // one-based index for the name suffix. |
| 312 for (int i = 1; i <= kMaxSwitches; ++i) { | 312 for (int i = 1; i <= kMaxSwitches; ++i) { |
| 313 g_custom_entries->push_back(google_breakpad::CustomInfoEntry( | 313 g_custom_entries->push_back(google_breakpad::CustomInfoEntry( |
| 314 base::StringPrintf(L"switch-%i", i).c_str(), L"")); | 314 base::StringPrintf(L"switch-%i", i).c_str(), L"")); |
| 315 } | 315 } |
| 316 | 316 |
| 317 // Fill in the command line arguments using CommandLine::ForCurrentProcess(). | 317 // Fill in the command line arguments using CommandLine::ForCurrentProcess(). |
| 318 // The browser process may call SetCommandLine() again later on with a command | 318 // The browser process may call SetCommandLine2() again later on with a |
| 319 // line that has been augmented with the about:flags experiments. | 319 // command line that has been augmented with the about:flags experiments. |
| 320 std::vector<const wchar_t*> switches; | 320 std::vector<const wchar_t*> switches; |
| 321 StringVectorToCStringVector( | 321 StringVectorToCStringVector( |
| 322 CommandLine::ForCurrentProcess()->argv(), &switches); | 322 CommandLine::ForCurrentProcess()->argv(), &switches); |
| 323 SetCommandLine(&switches[0], switches.size()); | 323 SetCommandLine2(&switches[0], switches.size()); |
| 324 | 324 |
| 325 if (type == L"renderer" || type == L"plugin" || type == L"gpu-process") { | 325 if (type == L"renderer" || type == L"plugin" || type == L"gpu-process") { |
| 326 g_num_of_views_offset = g_custom_entries->size(); | 326 g_num_of_views_offset = g_custom_entries->size(); |
| 327 g_custom_entries->push_back( | 327 g_custom_entries->push_back( |
| 328 google_breakpad::CustomInfoEntry(L"num-views", L"")); | 328 google_breakpad::CustomInfoEntry(L"num-views", L"")); |
| 329 // Create entries for the URL. Currently we only allow each chunk to be 64 | 329 // Create entries for the URL. Currently we only allow each chunk to be 64 |
| 330 // characters, which isn't enough for a URL. As a hack we create 8 entries | 330 // characters, which isn't enough for a URL. As a hack we create 8 entries |
| 331 // and split the URL across the g_custom_entries. | 331 // and split the URL across the g_custom_entries. |
| 332 g_url_chunks_offset = g_custom_entries->size(); | 332 g_url_chunks_offset = g_custom_entries->size(); |
| 333 // one-based index for the name suffix. | 333 // one-based index for the name suffix. |
| (...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 824 void InitDefaultCrashCallback(LPTOP_LEVEL_EXCEPTION_FILTER filter) { | 824 void InitDefaultCrashCallback(LPTOP_LEVEL_EXCEPTION_FILTER filter) { |
| 825 previous_filter = SetUnhandledExceptionFilter(filter); | 825 previous_filter = SetUnhandledExceptionFilter(filter); |
| 826 } | 826 } |
| 827 | 827 |
| 828 void StringVectorToCStringVector(const std::vector<std::wstring>& wstrings, | 828 void StringVectorToCStringVector(const std::vector<std::wstring>& wstrings, |
| 829 std::vector<const wchar_t*>* cstrings) { | 829 std::vector<const wchar_t*>* cstrings) { |
| 830 cstrings->clear(); | 830 cstrings->clear(); |
| 831 cstrings->reserve(wstrings.size()); | 831 cstrings->reserve(wstrings.size()); |
| 832 for (size_t i = 0; i < wstrings.size(); ++i) | 832 for (size_t i = 0; i < wstrings.size(); ++i) |
| 833 cstrings->push_back(wstrings[i].c_str()); | 833 cstrings->push_back(wstrings[i].c_str()); |
| 834 } | 834 } |
| OLD | NEW |