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

Side by Side Diff: ipc/ipc_channel_win.h

Issue 14383024: ipc: Use base::MessageLoop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #ifndef IPC_IPC_CHANNEL_WIN_H_ 5 #ifndef IPC_IPC_CHANNEL_WIN_H_
6 #define IPC_IPC_CHANNEL_WIN_H_ 6 #define IPC_IPC_CHANNEL_WIN_H_
7 7
8 #include "ipc/ipc_channel.h" 8 #include "ipc/ipc_channel.h"
9 9
10 #include <queue> 10 #include <queue>
11 #include <string> 11 #include <string>
12 12
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "base/message_loop.h" 15 #include "base/message_loop.h"
16 #include "ipc/ipc_channel_reader.h" 16 #include "ipc/ipc_channel_reader.h"
17 17
18 namespace base { 18 namespace base {
19 class ThreadChecker; 19 class ThreadChecker;
20 } 20 }
21 21
22 namespace IPC { 22 namespace IPC {
23 23
24 class Channel::ChannelImpl : public internal::ChannelReader, 24 class Channel::ChannelImpl : public internal::ChannelReader,
25 public MessageLoopForIO::IOHandler { 25 public base::MessageLoopForIO::IOHandler {
26 public: 26 public:
27 // Mirror methods of Channel, see ipc_channel.h for description. 27 // Mirror methods of Channel, see ipc_channel.h for description.
28 ChannelImpl(const IPC::ChannelHandle &channel_handle, Mode mode, 28 ChannelImpl(const IPC::ChannelHandle &channel_handle, Mode mode,
29 Listener* listener); 29 Listener* listener);
30 ~ChannelImpl(); 30 ~ChannelImpl();
31 bool Connect(); 31 bool Connect();
32 void Close(); 32 void Close();
33 bool Send(Message* message); 33 bool Send(Message* message);
34 static bool IsNamedServerInitialized(const std::string& channel_id); 34 static bool IsNamedServerInitialized(const std::string& channel_id);
35 base::ProcessId peer_pid() const { return peer_pid_; } 35 base::ProcessId peer_pid() const { return peer_pid_; }
36 36
37 private: 37 private:
38 // ChannelReader implementation. 38 // ChannelReader implementation.
39 virtual ReadState ReadData(char* buffer, 39 virtual ReadState ReadData(char* buffer,
40 int buffer_len, 40 int buffer_len,
41 int* bytes_read) OVERRIDE; 41 int* bytes_read) OVERRIDE;
42 virtual bool WillDispatchInputMessage(Message* msg) OVERRIDE; 42 virtual bool WillDispatchInputMessage(Message* msg) OVERRIDE;
43 bool DidEmptyInputBuffers() OVERRIDE; 43 bool DidEmptyInputBuffers() OVERRIDE;
44 virtual void HandleHelloMessage(const Message& msg) OVERRIDE; 44 virtual void HandleHelloMessage(const Message& msg) OVERRIDE;
45 45
46 static const string16 PipeName(const std::string& channel_id, 46 static const string16 PipeName(const std::string& channel_id,
47 int32* secret); 47 int32* secret);
48 bool CreatePipe(const IPC::ChannelHandle &channel_handle, Mode mode); 48 bool CreatePipe(const IPC::ChannelHandle &channel_handle, Mode mode);
49 49
50 bool ProcessConnection(); 50 bool ProcessConnection();
51 bool ProcessOutgoingMessages(MessageLoopForIO::IOContext* context, 51 bool ProcessOutgoingMessages(base::MessageLoopForIO::IOContext* context,
52 DWORD bytes_written); 52 DWORD bytes_written);
53 53
54 // MessageLoop::IOHandler implementation. 54 // MessageLoop::IOHandler implementation.
55 virtual void OnIOCompleted(MessageLoopForIO::IOContext* context, 55 virtual void OnIOCompleted(base::MessageLoopForIO::IOContext* context,
56 DWORD bytes_transfered, DWORD error); 56 DWORD bytes_transfered,
57 DWORD error);
58
57 private: 59 private:
58 struct State { 60 struct State {
59 explicit State(ChannelImpl* channel); 61 explicit State(ChannelImpl* channel);
60 ~State(); 62 ~State();
61 MessageLoopForIO::IOContext context; 63 base::MessageLoopForIO::IOContext context;
62 bool is_pending; 64 bool is_pending;
63 }; 65 };
64 66
65 State input_state_; 67 State input_state_;
66 State output_state_; 68 State output_state_;
67 69
68 HANDLE pipe_; 70 HANDLE pipe_;
69 71
70 base::ProcessId peer_pid_; 72 base::ProcessId peer_pid_;
71 73
(...skipping 23 matching lines...) Expand all
95 base::WeakPtrFactory<ChannelImpl> weak_factory_; 97 base::WeakPtrFactory<ChannelImpl> weak_factory_;
96 98
97 scoped_ptr<base::ThreadChecker> thread_check_; 99 scoped_ptr<base::ThreadChecker> thread_check_;
98 100
99 DISALLOW_COPY_AND_ASSIGN(ChannelImpl); 101 DISALLOW_COPY_AND_ASSIGN(ChannelImpl);
100 }; 102 };
101 103
102 } // namespace IPC 104 } // namespace IPC
103 105
104 #endif // IPC_IPC_CHANNEL_WIN_H_ 106 #endif // IPC_IPC_CHANNEL_WIN_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698