OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "chrome/common/profiling/memlog_sender.h" | 5 #include "chrome/common/profiling/memlog_sender.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/strings/utf_string_conversions.h" |
8 #include "chrome/common/chrome_switches.h" | 9 #include "chrome/common/chrome_switches.h" |
9 #include "chrome/common/profiling/memlog_allocator_shim.h" | 10 #include "chrome/common/profiling/memlog_allocator_shim.h" |
10 #include "chrome/common/profiling/memlog_sender_pipe.h" | 11 #include "chrome/common/profiling/memlog_sender_pipe.h" |
11 #include "chrome/common/profiling/memlog_stream.h" | 12 #include "chrome/common/profiling/memlog_stream.h" |
12 | 13 |
13 namespace profiling { | 14 namespace profiling { |
14 | 15 |
15 void InitMemlogSenderIfNecessary(const base::CommandLine& cmdline) { | 16 void InitMemlogSenderIfNecessary(const base::CommandLine& cmdline) { |
16 base::CommandLine::StringType pipe_id = | 17 std::string pipe_id = cmdline.GetSwitchValueASCII(switches::kMemlogPipe); |
17 cmdline.GetSwitchValueNative(switches::kMemlogPipe); | 18 if (!pipe_id.empty()) |
18 if (pipe_id.empty()) | 19 StartMemlogSender(pipe_id); |
19 return; // No pipe, don't run. | 20 } |
20 | 21 |
21 static MemlogSenderPipe pipe(pipe_id); | 22 void StartMemlogSender(const std::string& pipe_id) { |
| 23 static MemlogSenderPipe pipe(base::UTF8ToUTF16(pipe_id)); |
22 pipe.Connect(); | 24 pipe.Connect(); |
23 | 25 |
24 StreamHeader header; | 26 StreamHeader header; |
25 header.signature = kStreamSignature; | 27 header.signature = kStreamSignature; |
26 | 28 |
27 pipe.Send(&header, sizeof(StreamHeader)); | 29 pipe.Send(&header, sizeof(StreamHeader)); |
28 | 30 |
29 InitAllocatorShim(&pipe); | 31 InitAllocatorShim(&pipe); |
30 } | 32 } |
31 | 33 |
32 } // namespace profiling | 34 } // namespace profiling |
OLD | NEW |