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

Side by Side Diff: tools/ipc_fuzzer/replay/replay_process.cc

Issue 861113003: Fix issues with replay_process in ipc fuzzer. Make it compile on windows. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Log to both stderr, file since stderr is hard to get on windows. Created 5 years, 11 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
« no previous file with comments | « tools/ipc_fuzzer/play_testcase.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "tools/ipc_fuzzer/replay/replay_process.h" 5 #include "tools/ipc_fuzzer/replay/replay_process.h"
6 6
7 #include <limits.h> 7 #include <limits.h>
8 #include <string> 8 #include <string>
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/files/file_path.h" 11 #include "base/files/file_path.h"
12 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/posix/global_descriptors.h" 13 #include "base/posix/global_descriptors.h"
14 #include "chrome/common/chrome_switches.h" 14 #include "chrome/common/chrome_switches.h"
15 #include "ipc/ipc_descriptors.h" 15 #include "ipc/ipc_descriptors.h"
16 #include "ipc/ipc_switches.h" 16 #include "ipc/ipc_switches.h"
17 17
18 namespace ipc_fuzzer { 18 namespace ipc_fuzzer {
19 19
20 ReplayProcess::ReplayProcess() 20 ReplayProcess::ReplayProcess()
21 : io_thread_("Chrome_ChildIOThread"), 21 : io_thread_("Chrome_ChildIOThread"),
22 shutdown_event_(true, false), 22 shutdown_event_(true, false),
23 message_index_(0) { 23 message_index_(0) {
24 } 24 }
25 25
26 ReplayProcess::~ReplayProcess() { 26 ReplayProcess::~ReplayProcess() {
27 channel_.reset(); 27 channel_.reset();
28
29 // Signal this event before shutting down the service process. That way all
30 // background threads can cleanup.
31 shutdown_event_.Signal();
32 io_thread_.Stop();
28 } 33 }
29 34
30 bool ReplayProcess::Initialize(int argc, const char** argv) { 35 bool ReplayProcess::Initialize(int argc, const char** argv) {
31 base::CommandLine::Init(argc, argv); 36 base::CommandLine::Init(argc, argv);
32 37
33 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( 38 if (!base::CommandLine::ForCurrentProcess()->HasSwitch(
34 switches::kIpcFuzzerTestcase)) { 39 switches::kIpcFuzzerTestcase)) {
35 LOG(ERROR) << "This binary shouldn't be executed directly, " 40 LOG(ERROR) << "This binary shouldn't be executed directly, "
36 << "please use tools/ipc_fuzzer/play_testcase.py"; 41 << "please use tools/ipc_fuzzer/play_testcase.py";
37 return false; 42 return false;
38 } 43 }
39 44
40 // Log to default destination. 45 // Log to both stderr and file destinations.
41 logging::SetMinLogLevel(logging::LOG_ERROR); 46 logging::SetMinLogLevel(logging::LOG_ERROR);
42 logging::InitLogging(logging::LoggingSettings()); 47 logging::LoggingSettings settings;
48 settings.logging_dest = logging::LOG_TO_ALL;
49 settings.log_file = FILE_PATH_LITERAL("ipc_replay.log");
50 logging::InitLogging(settings);
43 51
44 io_thread_.StartWithOptions( 52 io_thread_.StartWithOptions(
45 base::Thread::Options(base::MessageLoop::TYPE_IO, 0)); 53 base::Thread::Options(base::MessageLoop::TYPE_IO, 0));
46 54
55 #if defined(OS_POSIX)
47 base::GlobalDescriptors* g_fds = base::GlobalDescriptors::GetInstance(); 56 base::GlobalDescriptors* g_fds = base::GlobalDescriptors::GetInstance();
48 g_fds->Set(kPrimaryIPCChannel, 57 g_fds->Set(kPrimaryIPCChannel,
49 kPrimaryIPCChannel + base::GlobalDescriptors::kBaseDescriptor); 58 kPrimaryIPCChannel + base::GlobalDescriptors::kBaseDescriptor);
59 #endif
60
50 return true; 61 return true;
51 } 62 }
52 63
53 void ReplayProcess::OpenChannel() { 64 void ReplayProcess::OpenChannel() {
54 std::string channel_name = 65 std::string channel_name =
55 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 66 base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
56 switches::kProcessChannelID); 67 switches::kProcessChannelID);
57 68
58 channel_ = IPC::ChannelProxy::Create(channel_name, 69 channel_ = IPC::ChannelProxy::Create(channel_name,
59 IPC::Channel::MODE_CLIENT, 70 IPC::Channel::MODE_CLIENT,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 return true; 109 return true;
99 } 110 }
100 111
101 void ReplayProcess::OnChannelError() { 112 void ReplayProcess::OnChannelError() {
102 LOG(ERROR) << "Channel error, quitting after " 113 LOG(ERROR) << "Channel error, quitting after "
103 << message_index_ << " messages"; 114 << message_index_ << " messages";
104 base::MessageLoop::current()->Quit(); 115 base::MessageLoop::current()->Quit();
105 } 116 }
106 117
107 } // namespace ipc_fuzzer 118 } // namespace ipc_fuzzer
OLDNEW
« no previous file with comments | « tools/ipc_fuzzer/play_testcase.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698