Chromium Code Reviews| Index: chrome/profiling/memlog_receiver_pipe_server_win.h |
| diff --git a/chrome/profiling/memlog_receiver_pipe_server_win.h b/chrome/profiling/memlog_receiver_pipe_server_win.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..59dcee2405f7c0599e654b1e41e7899fb1936fcb |
| --- /dev/null |
| +++ b/chrome/profiling/memlog_receiver_pipe_server_win.h |
| @@ -0,0 +1,66 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_PROFILING_MEMLOG_RECEIVER_PIPE_SERVER_WIN_H_ |
| +#define CHROME_PROFILING_MEMLOG_RECEIVER_PIPE_SERVER_WIN_H_ |
| + |
| +#include <memory> |
| + |
| +#include "base/callback_forward.h" |
| +#include "base/macros.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "base/message_loop/message_pump_win.h" |
| +#include "base/strings/string16.h" |
| +#include "chrome/profiling/memlog_receiver_pipe_win.h" |
| + |
| +namespace base { |
| +class TaskRunner; |
| +} |
|
awong
2017/06/15 21:32:47
} // namespace base
|
| + |
| +namespace profiling { |
| + |
| +class MemlogReceiverPipe; |
| + |
| +// This class listens for new pipe connections and creates new |
| +// MemlogReceiverPipe objects for each one. |
| +class MemlogReceiverPipeServer |
| + : public base::RefCountedThreadSafe<MemlogReceiverPipeServer> { |
| + public: |
| + using NewConnectionCallback = |
| + base::RepeatingCallback<void(scoped_refptr<MemlogReceiverPipe>)>; |
| + |
| + // |io_runner| is the task runner for the I/O thread. When a new connection is |
| + // established, the |on_new_conn| callback is called with the pipe. |
| + MemlogReceiverPipeServer(base::TaskRunner* io_runner, |
| + const std::string& pipe_id, |
| + NewConnectionCallback on_new_conn); |
| + ~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
|
| + |
| + 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.
|
| + on_new_connection_ = on_new_conn; |
| + } |
| + |
| + void Start(); |
|
awong
2017/06/15 21:32:47
Comment explaining what this does?
brettw
2017/06/15 22:12:22
Done.
|
| + |
| + private: |
| + base::string16 GetPipeName() const; |
| + |
| + HANDLE CreatePipeInstance(bool first_instance) const; |
| + |
| + // Called on the IO thread. |
| + void ScheduleNewConnection(bool first_instance); |
| + |
| + void OnIOCompleted(size_t bytes_transfered, DWORD error); |
| + |
| + scoped_refptr<base::TaskRunner> io_runner_; |
| + base::string16 pipe_id_; |
| + NewConnectionCallback on_new_connection_; |
| + |
| + // Current connection we're waiting on creation for. |
| + std::unique_ptr<MemlogReceiverPipe::CompletionThunk> current_; |
| +}; |
| + |
| +} // namespace profiling |
| + |
| +#endif // CHROME_PROFILING_MEMLOG_RECEIVER_PIPE_SERVER_WIN_H_ |