OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "base/files/file_path.h" | |
6 #include "base/logging.h" | |
7 #include "base/native_library.h" | |
8 #include "base/path_service.h" | |
9 #include "chrome/common/external_ipc_dumper.h" | |
10 | |
11 typedef IPC::ChannelProxy::OutgoingMessageFilter* (*GetFilterFunction)(); | |
12 typedef void (*SetDumpDirectoryFunction)(const base::FilePath&); | |
13 const char kSetDumpDirectoryEntryName[] = "SetDumpDirectory"; | |
inferno
2015/03/05 22:11:59
newline before this line.
inferno
2015/03/05 22:11:59
this line should come after kFilterEntryName.
| |
14 const char kFilterEntryName[] = "GetFilter"; | |
15 #if defined(OS_WIN) | |
inferno
2015/03/05 22:11:59
newline before this line.
| |
16 #define LIBRARY_NAME FILE_PATH_LITERAL("ipc_message_dump.dll") | |
inferno
2015/03/05 22:11:59
s/LIBRARY_NAME/IPC_MESSAGE_DUMP_MODULE/LIB/similar
| |
17 #else | |
18 #define LIBRARY_NAME FILE_PATH_LITERAL("libipc_message_dump.so") | |
19 #endif | |
20 | |
21 IPC::ChannelProxy::OutgoingMessageFilter* LoadExternalIPCDumper( | |
22 const base::FilePath& dump_directory) { | |
23 IPC::ChannelProxy::OutgoingMessageFilter* result = NULL; | |
24 | |
25 base::FilePath module_path; | |
26 if (!PathService::Get(base::DIR_MODULE, &module_path)) { | |
27 LOG(ERROR) << "PathService::Get failed."; | |
inferno
2015/03/05 22:11:59
Too cryptic error message. Something like "Ipc dum
| |
28 return result; | |
29 } | |
30 | |
31 base::FilePath library_path = module_path.Append(LIBRARY_NAME); | |
32 base::NativeLibraryLoadError load_error; | |
33 base::NativeLibrary library = | |
34 base::LoadNativeLibrary(library_path, &load_error); | |
35 | |
36 if (!library) { | |
37 LOG(ERROR) << load_error.ToString(); | |
38 return result; | |
39 } | |
40 | |
41 SetDumpDirectoryFunction set_directory_entry_point = | |
42 reinterpret_cast<SetDumpDirectoryFunction>( | |
43 base::GetFunctionPointerFromNativeLibrary( | |
44 library, kSetDumpDirectoryEntryName)); | |
45 if (set_directory_entry_point) | |
46 set_directory_entry_point(dump_directory); | |
inferno
2015/03/05 22:11:59
Should be LOG(ERROR) on failures for line 45 and l
| |
47 | |
48 GetFilterFunction filter_entry_point = reinterpret_cast<GetFilterFunction>( | |
49 base::GetFunctionPointerFromNativeLibrary(library, kFilterEntryName)); | |
50 if (filter_entry_point) | |
51 result = filter_entry_point(); | |
52 | |
53 return result; | |
54 } | |
OLD | NEW |