Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_PROFILING_MEMLOG_RECEIVER_PIPE_SERVER_WIN_H_ | |
| 6 #define CHROME_PROFILING_MEMLOG_RECEIVER_PIPE_SERVER_WIN_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 | |
| 10 #include "base/callback_forward.h" | |
| 11 #include "base/macros.h" | |
| 12 #include "base/memory/ref_counted.h" | |
| 13 #include "base/message_loop/message_pump_win.h" | |
| 14 #include "base/strings/string16.h" | |
| 15 #include "chrome/profiling/memlog_receiver_pipe_win.h" | |
| 16 | |
| 17 namespace base { | |
| 18 class TaskRunner; | |
| 19 } | |
|
awong
2017/06/15 21:32:47
} // namespace base
| |
| 20 | |
| 21 namespace profiling { | |
| 22 | |
| 23 class MemlogReceiverPipe; | |
| 24 | |
| 25 // This class listens for new pipe connections and creates new | |
| 26 // MemlogReceiverPipe objects for each one. | |
| 27 class MemlogReceiverPipeServer | |
| 28 : public base::RefCountedThreadSafe<MemlogReceiverPipeServer> { | |
| 29 public: | |
| 30 using NewConnectionCallback = | |
| 31 base::RepeatingCallback<void(scoped_refptr<MemlogReceiverPipe>)>; | |
| 32 | |
| 33 // |io_runner| is the task runner for the I/O thread. When a new connection is | |
| 34 // established, the |on_new_conn| callback is called with the pipe. | |
| 35 MemlogReceiverPipeServer(base::TaskRunner* io_runner, | |
| 36 const std::string& pipe_id, | |
| 37 NewConnectionCallback on_new_conn); | |
| 38 ~MemlogReceiverPipeServer(); | |
|
awong
2017/06/15 21:32:47
virtual?
brettw
2017/06/15 22:12:22
This shouldn't be necessary. The whole reason base
| |
| 39 | |
| 40 void set_on_new_connection(NewConnectionCallback on_new_conn) { | |
|
awong
2017/06/15 21:32:47
on_new_conn -> on_new_connection
brettw
2017/06/15 22:12:22
Done.
| |
| 41 on_new_connection_ = on_new_conn; | |
| 42 } | |
| 43 | |
| 44 void Start(); | |
|
awong
2017/06/15 21:32:47
Comment explaining what this does?
brettw
2017/06/15 22:12:22
Done.
| |
| 45 | |
| 46 private: | |
| 47 base::string16 GetPipeName() const; | |
| 48 | |
| 49 HANDLE CreatePipeInstance(bool first_instance) const; | |
| 50 | |
| 51 // Called on the IO thread. | |
| 52 void ScheduleNewConnection(bool first_instance); | |
| 53 | |
| 54 void OnIOCompleted(size_t bytes_transfered, DWORD error); | |
| 55 | |
| 56 scoped_refptr<base::TaskRunner> io_runner_; | |
| 57 base::string16 pipe_id_; | |
| 58 NewConnectionCallback on_new_connection_; | |
| 59 | |
| 60 // Current connection we're waiting on creation for. | |
| 61 std::unique_ptr<MemlogReceiverPipe::CompletionThunk> current_; | |
| 62 }; | |
| 63 | |
| 64 } // namespace profiling | |
| 65 | |
| 66 #endif // CHROME_PROFILING_MEMLOG_RECEIVER_PIPE_SERVER_WIN_H_ | |
| OLD | NEW |