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

Side by Side Diff: chrome_frame/chrome_tab.cc

Issue 12521002: Start and stop crash reporting outside of the loader lock. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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
OLDNEW
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 // chrome_tab.cc : Implementation of DLL Exports. 5 // chrome_tab.cc : Implementation of DLL Exports.
6 6
7 // Need to include this before the ATL headers below. 7 // Need to include this before the ATL headers below.
8 #include "chrome_frame/chrome_tab.h" 8 #include "chrome_frame/chrome_tab.h"
9 9
10 #include <atlsecurity.h> 10 #include <atlsecurity.h>
11 #include <objbase.h> 11 #include <objbase.h>
12 12
13 #include "base/at_exit.h" 13 #include "base/at_exit.h"
14 #include "base/basictypes.h"
14 #include "base/command_line.h" 15 #include "base/command_line.h"
15 #include "base/file_util.h" 16 #include "base/file_util.h"
16 #include "base/file_version_info.h" 17 #include "base/file_version_info.h"
17 #include "base/logging.h" 18 #include "base/logging.h"
18 #include "base/logging_win.h" 19 #include "base/logging_win.h"
19 #include "base/metrics/field_trial.h" 20 #include "base/metrics/field_trial.h"
20 #include "base/path_service.h" 21 #include "base/path_service.h"
21 #include "base/string16.h" 22 #include "base/string16.h"
22 #include "base/string_number_conversions.h" 23 #include "base/string_number_conversions.h"
23 #include "base/string_piece.h" 24 #include "base/string_piece.h"
(...skipping 17 matching lines...) Expand all
41 #include "chrome_frame/exception_barrier.h" 42 #include "chrome_frame/exception_barrier.h"
42 #include "chrome_frame/metrics_service.h" 43 #include "chrome_frame/metrics_service.h"
43 #include "chrome_frame/resource.h" 44 #include "chrome_frame/resource.h"
44 #include "chrome_frame/utils.h" 45 #include "chrome_frame/utils.h"
45 #include "googleurl/src/url_util.h" 46 #include "googleurl/src/url_util.h"
46 #include "grit/chrome_frame_resources.h" 47 #include "grit/chrome_frame_resources.h"
47 48
48 using base::win::RegKey; 49 using base::win::RegKey;
49 50
50 namespace { 51 namespace {
51 // This function has the side effect of initializing an unprotected
52 // vector pointer inside GoogleUrl. If this is called during DLL loading,
53 // it has the effect of avoiding an initialization race on that pointer.
54 // TODO(siggi): fix GoogleUrl.
55 void InitGoogleUrl() {
56 static const char kDummyUrl[] = "http://www.google.com";
57
58 url_util::IsStandard(kDummyUrl,
59 url_parse::MakeRange(0, arraysize(kDummyUrl)));
60 }
61 52
62 const wchar_t kInternetSettings[] = 53 const wchar_t kInternetSettings[] =
63 L"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"; 54 L"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings";
64 55
65 const wchar_t kProtocolHandlers[] = 56 const wchar_t kProtocolHandlers[] =
66 L"Software\\Classes\\Protocols\\Handler"; 57 L"Software\\Classes\\Protocols\\Handler";
67 58
68 const wchar_t kRunOnce[] = 59 const wchar_t kRunOnce[] =
69 L"Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce"; 60 L"Software\\Microsoft\\Windows\\CurrentVersion\\RunOnce";
70 61
71 const wchar_t kRunKeyName[] = L"ChromeFrameHelper"; 62 const wchar_t kRunKeyName[] = L"ChromeFrameHelper";
72 63
73 const wchar_t kChromeFrameHelperExe[] = L"chrome_frame_helper.exe"; 64 const wchar_t kChromeFrameHelperExe[] = L"chrome_frame_helper.exe";
74 const wchar_t kChromeFrameHelperStartupArg[] = L"--startup"; 65 const wchar_t kChromeFrameHelperStartupArg[] = L"--startup";
75 66
76 // Window class and window names. 67 // Window class and window names.
77 // TODO(robertshield): These and other constants need to be refactored into 68 // TODO(robertshield): These and other constants need to be refactored into
78 // a common chrome_frame_constants.h|cc and built into a separate lib 69 // a common chrome_frame_constants.h|cc and built into a separate lib
79 // (either chrome_frame_utils or make another one). 70 // (either chrome_frame_utils or make another one).
80 const wchar_t kChromeFrameHelperWindowClassName[] = 71 const wchar_t kChromeFrameHelperWindowClassName[] =
81 L"ChromeFrameHelperWindowClass"; 72 L"ChromeFrameHelperWindowClass";
82 const wchar_t kChromeFrameHelperWindowName[] = 73 const wchar_t kChromeFrameHelperWindowName[] =
83 L"ChromeFrameHelperWindowName"; 74 L"ChromeFrameHelperWindowName";
84 75
85 // {0562BFC3-2550-45b4-BD8E-A310583D3A6F} 76 // {0562BFC3-2550-45b4-BD8E-A310583D3A6F}
86 static const GUID kChromeFrameProvider = 77 const GUID kChromeFrameProvider =
87 { 0x562bfc3, 0x2550, 0x45b4, 78 { 0x562bfc3, 0x2550, 0x45b4,
88 { 0xbd, 0x8e, 0xa3, 0x10, 0x58, 0x3d, 0x3a, 0x6f } }; 79 { 0xbd, 0x8e, 0xa3, 0x10, 0x58, 0x3d, 0x3a, 0x6f } };
89 80
90 const wchar_t kPostPlatformUAKey[] = 81 const wchar_t kPostPlatformUAKey[] =
91 L"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\" 82 L"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\"
92 L"User Agent\\Post Platform"; 83 L"User Agent\\Post Platform";
93 const wchar_t kChromeFramePrefix[] = L"chromeframe/"; 84 const wchar_t kChromeFramePrefix[] = L"chromeframe/";
94 85
95 // See comments in DllGetClassObject. 86 // See comments in DllGetClassObject.
96 LPFNGETCLASSOBJECT g_dll_get_class_object_redir_ptr = NULL; 87 LPFNGETCLASSOBJECT g_dll_get_class_object_redir_ptr = NULL;
97 88
89 // This function has the side effect of initializing an unprotected
90 // vector pointer inside GoogleUrl. If this is called during DLL loading,
91 // it has the effect of avoiding an initialization race on that pointer.
92 // TODO(siggi): fix GoogleUrl.
93 void InitGoogleUrl() {
94 static const char kDummyUrl[] = "http://www.google.com";
95
96 url_util::IsStandard(kDummyUrl,
97 url_parse::MakeRange(0, arraysize(kDummyUrl)));
98 }
99
98 class ChromeTabModule : public CAtlDllModuleT<ChromeTabModule> { 100 class ChromeTabModule : public CAtlDllModuleT<ChromeTabModule> {
99 public: 101 public:
100 typedef CAtlDllModuleT<ChromeTabModule> ParentClass; 102 typedef CAtlDllModuleT<ChromeTabModule> ParentClass;
101 103
102 ChromeTabModule() : do_system_registration_(true) {} 104 ChromeTabModule() : do_system_registration_(true) {}
103 105
104 DECLARE_LIBID(LIBID_ChromeTabLib) 106 DECLARE_LIBID(LIBID_ChromeTabLib)
105 DECLARE_REGISTRY_APPID_RESOURCEID(IDR_CHROMETAB, 107 DECLARE_REGISTRY_APPID_RESOURCEID(IDR_CHROMETAB,
106 "{FD9B1B31-F4D8-436A-8F4F-D3C2E36733D3}") 108 "{FD9B1B31-F4D8-436A-8F4F-D3C2E36733D3}")
107 109
(...skipping 714 matching lines...) Expand 10 before | Expand all | Expand 10 after
822 if (reason == DLL_PROCESS_ATTACH) { 824 if (reason == DLL_PROCESS_ATTACH) {
823 #ifndef NDEBUG 825 #ifndef NDEBUG
824 // Silence traces from the ATL registrar to reduce the log noise. 826 // Silence traces from the ATL registrar to reduce the log noise.
825 ATL::CTrace::s_trace.ChangeCategory(atlTraceRegistrar, 0, 827 ATL::CTrace::s_trace.ChangeCategory(atlTraceRegistrar, 0,
826 ATLTRACESTATUS_DISABLED); 828 ATLTRACESTATUS_DISABLED);
827 #endif 829 #endif
828 InitGoogleUrl(); 830 InitGoogleUrl();
829 831
830 g_exit_manager = new base::AtExitManager(); 832 g_exit_manager = new base::AtExitManager();
831 CommandLine::Init(0, NULL); 833 CommandLine::Init(0, NULL);
832 InitializeCrashReporting();
robertshield 2013/03/06 13:50:32 Can we move any of the rest of this code out of Dl
grt (UTC plus 2) 2013/03/11 15:35:11 I left the rest here for some reason that I can't
833 logging::InitLogging( 834 logging::InitLogging(
834 NULL, 835 NULL,
835 logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG, 836 logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG,
836 logging::LOCK_LOG_FILE, 837 logging::LOCK_LOG_FILE,
837 logging::DELETE_OLD_LOG_FILE, 838 logging::DELETE_OLD_LOG_FILE,
838 logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS); 839 logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS);
839 840
840 // Log the same items as Chrome. 841 // Log the same items as Chrome.
841 logging::SetLogItems(true, // enable_process_id 842 logging::SetLogItems(true, // enable_process_id
842 true, // enable_thread_id 843 true, // enable_thread_id
(...skipping 24 matching lines...) Expand all
867 g_field_trial_list = NULL; 868 g_field_trial_list = NULL;
868 869
869 DllRedirector* dll_redirector = DllRedirector::GetInstance(); 870 DllRedirector* dll_redirector = DllRedirector::GetInstance();
870 DCHECK(dll_redirector); 871 DCHECK(dll_redirector);
871 dll_redirector->UnregisterAsFirstCFModule(); 872 dll_redirector->UnregisterAsFirstCFModule();
872 873
873 g_patch_helper.UnpatchIfNeeded(); 874 g_patch_helper.UnpatchIfNeeded();
874 875
875 delete g_exit_manager; 876 delete g_exit_manager;
876 g_exit_manager = NULL; 877 g_exit_manager = NULL;
877
878 ShutdownCrashReporting();
879 } 878 }
880 return _AtlModule.DllMain(reason, reserved); 879 return _AtlModule.DllMain(reason, reserved);
881 } 880 }
882 881
883 // Used to determine whether the DLL can be unloaded by OLE 882 // Used to determine whether the DLL can be unloaded by OLE
884 STDAPI DllCanUnloadNow() { 883 STDAPI DllCanUnloadNow() {
885 return _AtlModule.DllCanUnloadNow(); 884 if (!_AtlModule.DllCanUnloadNow())
885 return false;
886
887 // Stop crash reporting now, or when the last ScopedCrashReporting destructs.
888 CrashReportingManager::Decommit();
889 return true;
robertshield 2013/03/06 13:50:32 Why shutdown here rather than in DllMain? Does shu
grt (UTC plus 2) 2013/03/11 15:35:11 Yes. The hang observed happens during shutdown, in
886 } 890 }
887 891
888 // Returns a class factory to create an object of the requested type 892 // Returns a class factory to create an object of the requested type
889 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv) { 893 STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv) {
894 ScopedCrashReporting crash_reporting;
895
890 // If we found another module present when we were loaded, then delegate to 896 // If we found another module present when we were loaded, then delegate to
891 // that: 897 // that:
892 if (g_dll_get_class_object_redir_ptr) { 898 if (g_dll_get_class_object_redir_ptr) {
893 return g_dll_get_class_object_redir_ptr(rclsid, riid, ppv); 899 return g_dll_get_class_object_redir_ptr(rclsid, riid, ppv);
894 } 900 }
895 901
896 // Enable sniffing and switching only if asked for BHO 902 // Enable sniffing and switching only if asked for BHO
897 // (we use BHO to get loaded in IE). 903 // (we use BHO to get loaded in IE).
898 if (rclsid == CLSID_ChromeFrameBHO) { 904 if (rclsid == CLSID_ChromeFrameBHO)
899 g_patch_helper.InitializeAndPatchProtocolsIfNeeded(); 905 g_patch_helper.InitializeAndPatchProtocolsIfNeeded();
900 }
901 906
902 return _AtlModule.DllGetClassObject(rclsid, riid, ppv); 907 HRESULT hr = _AtlModule.DllGetClassObject(rclsid, riid, ppv);
908
909 // Keep crash reporting going if an instance is being returned. It will be
910 // stopped in DllCanUnloadNow.
911 if (SUCCEEDED(hr) && *ppv)
912 crash_reporting.Commit();
913
914 return hr;
903 } 915 }
904 916
905 // DllRegisterServer - Adds entries to the system registry 917 // DllRegisterServer - Adds entries to the system registry
906 STDAPI DllRegisterServer() { 918 STDAPI DllRegisterServer() {
919 ScopedCrashReporting crash_reporting;
907 uint16 flags = ACTIVEX | ACTIVEDOC | TYPELIB | GCF_PROTOCOL | 920 uint16 flags = ACTIVEX | ACTIVEDOC | TYPELIB | GCF_PROTOCOL |
908 BHO_CLSID | BHO_REGISTRATION; 921 BHO_CLSID | BHO_REGISTRATION;
909 922
910 HRESULT hr = CustomRegistration(flags, true, true); 923 HRESULT hr = CustomRegistration(flags, true, true);
911 if (SUCCEEDED(hr)) { 924 if (SUCCEEDED(hr)) {
912 SetupRunOnce(); 925 SetupRunOnce();
913 } 926 }
914 927
915 return hr; 928 return hr;
916 } 929 }
917 930
918 // DllUnregisterServer - Removes entries from the system registry 931 // DllUnregisterServer - Removes entries from the system registry
919 STDAPI DllUnregisterServer() { 932 STDAPI DllUnregisterServer() {
933 ScopedCrashReporting crash_reporting;
920 HRESULT hr = CustomRegistration(ALL, false, true); 934 HRESULT hr = CustomRegistration(ALL, false, true);
921 return hr; 935 return hr;
922 } 936 }
923 937
924 // DllRegisterUserServer - Adds entries to the HKCU hive in the registry. 938 // DllRegisterUserServer - Adds entries to the HKCU hive in the registry.
925 STDAPI DllRegisterUserServer() { 939 STDAPI DllRegisterUserServer() {
940 ScopedCrashReporting crash_reporting;
926 UINT flags = ACTIVEX | ACTIVEDOC | TYPELIB | GCF_PROTOCOL | 941 UINT flags = ACTIVEX | ACTIVEDOC | TYPELIB | GCF_PROTOCOL |
927 BHO_CLSID | BHO_REGISTRATION; 942 BHO_CLSID | BHO_REGISTRATION;
928 943
929 HRESULT hr = CustomRegistration(flags, TRUE, false); 944 HRESULT hr = CustomRegistration(flags, TRUE, false);
930 if (SUCCEEDED(hr)) { 945 if (SUCCEEDED(hr)) {
931 SetupRunOnce(); 946 SetupRunOnce();
932 } 947 }
933 948
934 return hr; 949 return hr;
935 } 950 }
936 951
937 // DllUnregisterUserServer - Removes entries from the HKCU hive in the registry. 952 // DllUnregisterUserServer - Removes entries from the HKCU hive in the registry.
938 STDAPI DllUnregisterUserServer() { 953 STDAPI DllUnregisterUserServer() {
954 ScopedCrashReporting crash_reporting;
939 HRESULT hr = CustomRegistration(ALL, FALSE, false); 955 HRESULT hr = CustomRegistration(ALL, FALSE, false);
940 return hr; 956 return hr;
941 } 957 }
942 958
943 // Object entries go here instead of with each object, so that we can move 959 // Object entries go here instead of with each object, so that we can move
944 // the objects to a lib. Also reduces magic. 960 // the objects to a lib. Also reduces magic.
945 OBJECT_ENTRY_AUTO(CLSID_ChromeFrameBHO, Bho) 961 OBJECT_ENTRY_AUTO(CLSID_ChromeFrameBHO, Bho)
946 OBJECT_ENTRY_AUTO(__uuidof(ChromeActiveDocument), ChromeActiveDocument) 962 OBJECT_ENTRY_AUTO(__uuidof(ChromeActiveDocument), ChromeActiveDocument)
947 OBJECT_ENTRY_AUTO(__uuidof(ChromeFrame), ChromeFrameActivex) 963 OBJECT_ENTRY_AUTO(__uuidof(ChromeFrame), ChromeFrameActivex)
948 OBJECT_ENTRY_AUTO(__uuidof(ChromeProtocol), ChromeProtocol) 964 OBJECT_ENTRY_AUTO(__uuidof(ChromeProtocol), ChromeProtocol)
OLDNEW
« chrome_frame/chrome_frame_reporting.h ('K') | « chrome_frame/chrome_frame_reporting.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698