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

Side by Side Diff: chrome/common/external_ipc_dumper.cc

Issue 975903002: Add a flag to dump IPC messages sent from the renderer to the browser. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup in external_ipc_dumper.cc Created 5 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
OLDNEW
(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)(base::FilePath&);
13 const char kSetDumpDirectoryEntryName[] = "SetDumpDirectory";
14 const char kFilterEntryName[] = "GetFilter";
15 #if defined(OS_WIN)
16 #define LIBRARY_NAME FILE_PATH_LITERAL("ipc_message_dump.dll")
17 #else
18 #define LIBRARY_NAME FILE_PATH_LITERAL("libipc_message_dump.so")
19 #endif
20
21 IPC::ChannelProxy::OutgoingMessageFilter* LoadExternalIPCDumper(
22 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.";
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);
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 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698