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

Side by Side Diff: ipc/ipc_channel_win.h

Issue 9568031: Refactoring on Windows IPC channel. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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
« no previous file with comments | « no previous file | ipc/ipc_channel_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #pragma once 7 #pragma once
8 8
9 #include "ipc/ipc_channel.h" 9 #include "ipc/ipc_channel.h"
10 10
(...skipping 14 matching lines...) Expand all
25 public: 25 public:
26 // Mirror methods of Channel, see ipc_channel.h for description. 26 // Mirror methods of Channel, see ipc_channel.h for description.
27 ChannelImpl(const IPC::ChannelHandle &channel_handle, Mode mode, 27 ChannelImpl(const IPC::ChannelHandle &channel_handle, Mode mode,
28 Listener* listener); 28 Listener* listener);
29 ~ChannelImpl(); 29 ~ChannelImpl();
30 bool Connect(); 30 bool Connect();
31 void Close(); 31 void Close();
32 void set_listener(Listener* listener) { listener_ = listener; } 32 void set_listener(Listener* listener) { listener_ = listener; }
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
35 private: 36 private:
37 enum ReadState { READ_SUCCEEDED, READ_FAILED, READ_PENDING };
38
39 // This will become the virtual interface implemented by this class to
40 // handle platform-specific reading.
41 // TODO(brettw) finish refactoring.
42 ReadState ReadData(char* buffer, int buffer_len, int* bytes_read);
43 bool WillDispatchInputMessage(Message* msg);
44 void HandleHelloMessage(const Message& msg);
45 bool DidEmptyInputBuffers();
46
47 bool DispatchInputData(const char* input_data, int input_data_len);
48
49 // Returns true if the given message is the hello message.
50 bool IsHelloMessage(const Message& m) const;
51
52 // Handles asynchronously read data.
53 //
54 // Optionally call this after returning READ_PENDING from ReadData to
55 // indicate that buffer was filled with the given number of bytes of
56 // data. See ReadData for more.
57 bool AsyncReadComplete(int bytes_read);
58
36 static const std::wstring PipeName(const std::string& channel_id); 59 static const std::wstring PipeName(const std::string& channel_id);
37 bool CreatePipe(const IPC::ChannelHandle &channel_handle, Mode mode); 60 bool CreatePipe(const IPC::ChannelHandle &channel_handle, Mode mode);
38 61
39 bool ProcessConnection(); 62 bool ProcessConnection();
40 bool ProcessIncomingMessages(MessageLoopForIO::IOContext* context, 63 bool ProcessIncomingMessages();
41 DWORD bytes_read);
42 bool ProcessOutgoingMessages(MessageLoopForIO::IOContext* context, 64 bool ProcessOutgoingMessages(MessageLoopForIO::IOContext* context,
43 DWORD bytes_written); 65 DWORD bytes_written);
44 66
45 // MessageLoop::IOHandler implementation. 67 // MessageLoop::IOHandler implementation.
46 virtual void OnIOCompleted(MessageLoopForIO::IOContext* context, 68 virtual void OnIOCompleted(MessageLoopForIO::IOContext* context,
47 DWORD bytes_transfered, DWORD error); 69 DWORD bytes_transfered, DWORD error);
48 private: 70 private:
49 struct State { 71 struct State {
50 explicit State(ChannelImpl* channel); 72 explicit State(ChannelImpl* channel);
51 ~State(); 73 ~State();
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 base::WeakPtrFactory<ChannelImpl> weak_factory_; 105 base::WeakPtrFactory<ChannelImpl> weak_factory_;
84 106
85 scoped_ptr<base::NonThreadSafe> thread_check_; 107 scoped_ptr<base::NonThreadSafe> thread_check_;
86 108
87 DISALLOW_COPY_AND_ASSIGN(ChannelImpl); 109 DISALLOW_COPY_AND_ASSIGN(ChannelImpl);
88 }; 110 };
89 111
90 } // namespace IPC 112 } // namespace IPC
91 113
92 #endif // IPC_IPC_CHANNEL_WIN_H_ 114 #endif // IPC_IPC_CHANNEL_WIN_H_
OLDNEW
« no previous file with comments | « no previous file | ipc/ipc_channel_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698