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

Side by Side Diff: ipc/ipc_channel_reader.h

Issue 25325002: workaround for mac kernel bug (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: minor bugfix Created 7 years, 2 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 | « ipc/ipc_channel_posix.cc ('k') | ipc/ipc_channel_reader.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) 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_READER_H_ 5 #ifndef IPC_IPC_CHANNEL_READER_H_
6 #define IPC_IPC_CHANNEL_READER_H_ 6 #define IPC_IPC_CHANNEL_READER_H_
7 7
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "ipc/ipc_channel.h" 9 #include "ipc/ipc_channel.h"
10 10
(...skipping 24 matching lines...) Expand all
35 // succeeded, although there may not have been any messages processed. 35 // succeeded, although there may not have been any messages processed.
36 bool ProcessIncomingMessages(); 36 bool ProcessIncomingMessages();
37 37
38 // Handles asynchronously read data. 38 // Handles asynchronously read data.
39 // 39 //
40 // Optionally call this after returning READ_PENDING from ReadData to 40 // Optionally call this after returning READ_PENDING from ReadData to
41 // indicate that buffer was filled with the given number of bytes of 41 // indicate that buffer was filled with the given number of bytes of
42 // data. See ReadData for more. 42 // data. See ReadData for more.
43 bool AsyncReadComplete(int bytes_read); 43 bool AsyncReadComplete(int bytes_read);
44 44
45 // Returns true if the given message is the "hello" message sent on channel 45 // Returns true if the given message is internal to the IPC implementation,
46 // set-up. 46 // like the "hello" message sent on channel set-up.
47 bool IsInternalMessage(const Message& m) const;
48
49 // Returns true if the given message is an Hello message
50 // sent on channel set-up.
47 bool IsHelloMessage(const Message& m) const; 51 bool IsHelloMessage(const Message& m) const;
48 52
49 protected: 53 protected:
50 enum ReadState { READ_SUCCEEDED, READ_FAILED, READ_PENDING }; 54 enum ReadState { READ_SUCCEEDED, READ_FAILED, READ_PENDING };
51 55
52 Listener* listener() const { return listener_; } 56 Listener* listener() const { return listener_; }
53 57
54 // Populates the given buffer with data from the pipe. 58 // Populates the given buffer with data from the pipe.
55 // 59 //
56 // Returns the state of the read. On READ_SUCCESS, the number of bytes 60 // Returns the state of the read. On READ_SUCCESS, the number of bytes
(...skipping 12 matching lines...) Expand all
69 // on success. False means a fatal channel error. 73 // on success. False means a fatal channel error.
70 // 74 //
71 // This will read from the input_fds_ and read more handles from the FD 75 // This will read from the input_fds_ and read more handles from the FD
72 // pipe if necessary. 76 // pipe if necessary.
73 virtual bool WillDispatchInputMessage(Message* msg) = 0; 77 virtual bool WillDispatchInputMessage(Message* msg) = 0;
74 78
75 // Performs post-dispatch checks. Called when all input buffers are empty, 79 // Performs post-dispatch checks. Called when all input buffers are empty,
76 // though there could be more data ready to be read from the OS. 80 // though there could be more data ready to be read from the OS.
77 virtual bool DidEmptyInputBuffers() = 0; 81 virtual bool DidEmptyInputBuffers() = 0;
78 82
79 // Handles the first message sent over the pipe which contains setup info. 83 // Handles internal messages, like the hello message sent on channel startup.
80 virtual void HandleHelloMessage(const Message& msg) = 0; 84 virtual void HandleInternalMessage(const Message& msg) = 0;
81 85
82 private: 86 private:
83 // Takes the given data received from the IPC channel and dispatches any 87 // Takes the given data received from the IPC channel and dispatches any
84 // fully completed messages. 88 // fully completed messages.
85 // 89 //
86 // Returns true on success. False means channel error. 90 // Returns true on success. False means channel error.
87 bool DispatchInputData(const char* input_data, int input_data_len); 91 bool DispatchInputData(const char* input_data, int input_data_len);
88 92
89 Listener* listener_; 93 Listener* listener_;
90 94
91 // We read from the pipe into this buffer. Managed by DispatchInputData, do 95 // We read from the pipe into this buffer. Managed by DispatchInputData, do
92 // not access directly outside that function. 96 // not access directly outside that function.
93 char input_buf_[Channel::kReadBufferSize]; 97 char input_buf_[Channel::kReadBufferSize];
94 98
95 // Large messages that span multiple pipe buffers, get built-up using 99 // Large messages that span multiple pipe buffers, get built-up using
96 // this buffer. 100 // this buffer.
97 std::string input_overflow_buf_; 101 std::string input_overflow_buf_;
98 102
99 DISALLOW_COPY_AND_ASSIGN(ChannelReader); 103 DISALLOW_COPY_AND_ASSIGN(ChannelReader);
100 }; 104 };
101 105
102 } // namespace internal 106 } // namespace internal
103 } // namespace IPC 107 } // namespace IPC
104 108
105 #endif // IPC_IPC_CHANNEL_READER_H_ 109 #endif // IPC_IPC_CHANNEL_READER_H_
OLDNEW
« no previous file with comments | « ipc/ipc_channel_posix.cc ('k') | ipc/ipc_channel_reader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698