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

Side by Side Diff: ipc/mojo/ipc_mojo_bootstrap.h

Issue 892503002: Revert of Revert of IPC::ChannelMojo: Make IPC handling robust against bad messages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « no previous file | ipc/mojo/ipc_mojo_bootstrap.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_MOJO_IPC_MOJO_BOOTSTRAP_H_ 5 #ifndef IPC_MOJO_IPC_MOJO_BOOTSTRAP_H_
6 #define IPC_MOJO_IPC_MOJO_BOOTSTRAP_H_ 6 #define IPC_MOJO_IPC_MOJO_BOOTSTRAP_H_
7 7
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/process/process_handle.h" 9 #include "base/process/process_handle.h"
10 #include "ipc/ipc_channel.h" 10 #include "ipc/ipc_channel.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 48
49 // Each client should call this once the process handle becomes known. 49 // Each client should call this once the process handle becomes known.
50 virtual void OnClientLaunched(base::ProcessHandle process) = 0; 50 virtual void OnClientLaunched(base::ProcessHandle process) = 0;
51 51
52 #if defined(OS_POSIX) && !defined(OS_NACL) 52 #if defined(OS_POSIX) && !defined(OS_NACL)
53 int GetClientFileDescriptor() const; 53 int GetClientFileDescriptor() const;
54 base::ScopedFD TakeClientFileDescriptor(); 54 base::ScopedFD TakeClientFileDescriptor();
55 #endif // defined(OS_POSIX) && !defined(OS_NACL) 55 #endif // defined(OS_POSIX) && !defined(OS_NACL)
56 56
57 protected: 57 protected:
58 // On MojoServerBootstrap: INITIALIZED -> WAITING_ACK -> READY
59 // On MojoClientBootstrap: INITIALIZED -> READY
60 // STATE_ERROR is a catch-all state that captures any observed error.
58 enum State { STATE_INITIALIZED, STATE_WAITING_ACK, STATE_READY, STATE_ERROR }; 61 enum State { STATE_INITIALIZED, STATE_WAITING_ACK, STATE_READY, STATE_ERROR };
59 62
60 Delegate* delegate() const { return delegate_; } 63 Delegate* delegate() const { return delegate_; }
61 bool Send(Message* message); 64 bool Send(Message* message);
62 void Fail(); 65 void Fail();
63 bool HasFailed() const; 66 bool HasFailed() const;
64 67
65 State state() const { return state_; } 68 State state() const { return state_; }
66 void set_state(State state) { state_ = state; } 69 void set_state(State state) { state_ = state; }
67 70
68 private: 71 private:
69 void Init(scoped_ptr<Channel> channel, Delegate* delegate); 72 void Init(scoped_ptr<Channel> channel, Delegate* delegate);
70 73
71 // Listener implementations 74 // Listener implementations
72 void OnBadMessageReceived(const Message& message) override; 75 void OnBadMessageReceived(const Message& message) override;
73 void OnChannelError() override; 76 void OnChannelError() override;
74 77
75 scoped_ptr<Channel> channel_; 78 scoped_ptr<Channel> channel_;
76 Delegate* delegate_; 79 Delegate* delegate_;
77 State state_; 80 State state_;
78 81
79 DISALLOW_COPY_AND_ASSIGN(MojoBootstrap); 82 DISALLOW_COPY_AND_ASSIGN(MojoBootstrap);
80 }; 83 };
81 84
82 } // namespace IPC 85 } // namespace IPC
83 86
84 #endif // IPC_MOJO_IPC_MOJO_BOOTSTRAP_H_ 87 #endif // IPC_MOJO_IPC_MOJO_BOOTSTRAP_H_
OLDNEW
« no previous file with comments | « no previous file | ipc/mojo/ipc_mojo_bootstrap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698