Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <windows.h> | 5 #include <windows.h> |
| 6 #include <tchar.h> | 6 #include <tchar.h> |
| 7 | 7 |
| 8 #include "base/at_exit.h" | 8 #include "base/at_exit.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "chrome/app/breakpad_win.h" | 10 #include "chrome/app/breakpad_win.h" |
| 11 #include "chrome/app/client_util.h" | 11 #include "chrome/app/client_util.h" |
| 12 #include "chrome/app/metro_driver_win.h" | 12 #include "chrome/app/metro_driver_win.h" |
| 13 #include "content/public/app/startup_helper_win.h" | 13 #include "content/public/app/startup_helper_win.h" |
| 14 #include "content/public/common/result_codes.h" | 14 #include "content/public/common/result_codes.h" |
| 15 #include "sandbox/win/src/sandbox_factory.h" | 15 #include "sandbox/win/src/sandbox_factory.h" |
| 16 | 16 |
| 17 namespace { | 17 namespace { |
| 18 | 18 |
| 19 // TODO(jschuh): Remove this after we narrow down the cause of the crashes. | 19 // TODO(jschuh): Remove this after we narrow down the cause of the crashes. |
| 20 class ThreadTracker { | 20 class ThreadTracker { |
| 21 public: | 21 public: |
| 22 static void NTAPI UpdateCount(PVOID module, DWORD reason, PVOID reserved) { | 22 static void NTAPI UpdateCount(PVOID module, DWORD reason, PVOID reserved) { |
| 23 if (reason == DLL_THREAD_ATTACH) { | 23 if (reason == DLL_THREAD_ATTACH) { |
| 24 if (::InterlockedIncrement(&count_) > cap_) | 24 if (::InterlockedIncrement(&count_) > cap_) { |
| 25 __debugbreak(); | 25 cap_ = LONG_MAX; |
| 26 // We schedule a callback, because the loader would eat an exception. | |
| 27 ::QueueUserAPC(CrashProcessCallback, ::GetCurrentThread(), NULL); | |
| 28 } | |
| 26 } else if (reason == DLL_THREAD_DETACH) { | 29 } else if (reason == DLL_THREAD_DETACH) { |
| 27 ::InterlockedDecrement(&count_); | 30 ::InterlockedDecrement(&count_); |
| 28 } | 31 } |
| 29 } | 32 } |
| 30 | 33 |
| 31 static void SetCap(LONG cap) { cap_ = cap; } | 34 static void SetCap(LONG cap) { cap_ = cap; } |
| 35 static void CALLBACK CrashProcessCallback(ULONG_PTR) { __debugbreak(); } | |
|
cpu_(ooo_6.6-7.5)
2012/09/16 00:19:10
move to private
| |
| 32 | 36 |
| 33 private: | 37 private: |
| 34 static LONG volatile count_; | 38 static LONG volatile count_; |
| 35 static LONG volatile cap_; | 39 static LONG volatile cap_; |
| 36 }; | 40 }; |
| 37 | 41 |
| 38 LONG volatile ThreadTracker::count_ = 1; | 42 LONG volatile ThreadTracker::count_ = 1; |
| 39 LONG volatile ThreadTracker::cap_ = LONG_MAX; | 43 LONG volatile ThreadTracker::cap_ = LONG_MAX; |
| 40 | 44 |
| 41 } // namespace | 45 } // namespace |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 80 CommandLine::Init(0, NULL); | 84 CommandLine::Init(0, NULL); |
| 81 // The exit manager is in charge of calling the dtors of singletons. | 85 // The exit manager is in charge of calling the dtors of singletons. |
| 82 base::AtExitManager exit_manager; | 86 base::AtExitManager exit_manager; |
| 83 | 87 |
| 84 MetroDriver metro_driver; | 88 MetroDriver metro_driver; |
| 85 if (metro_driver.in_metro_mode()) | 89 if (metro_driver.in_metro_mode()) |
| 86 return metro_driver.RunInMetro(instance, &RunChrome); | 90 return metro_driver.RunInMetro(instance, &RunChrome); |
| 87 // Not in metro mode, proceed as normal. | 91 // Not in metro mode, proceed as normal. |
| 88 return RunChrome(instance); | 92 return RunChrome(instance); |
| 89 } | 93 } |
| OLD | NEW |