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

Side by Side Diff: mojo/system/handle_table.h

Issue 277343004: Mojo: Delete some old, unused code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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
« no previous file with comments | « mojo/system/core.cc ('k') | no next file » | 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 MOJO_SYSTEM_HANDLE_TABLE_H_ 5 #ifndef MOJO_SYSTEM_HANDLE_TABLE_H_
6 #define MOJO_SYSTEM_HANDLE_TABLE_H_ 6 #define MOJO_SYSTEM_HANDLE_TABLE_H_
7 7
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 void RemoveBusyHandles(const MojoHandle* handles, uint32_t num_handles); 94 void RemoveBusyHandles(const MojoHandle* handles, uint32_t num_handles);
95 95
96 // Restores the given handles, which must all be present and which should have 96 // Restores the given handles, which must all be present and which should have
97 // previously been marked busy by |MarkBusyAndStartTransport()|, to a non-busy 97 // previously been marked busy by |MarkBusyAndStartTransport()|, to a non-busy
98 // state. 98 // state.
99 void RestoreBusyHandles(const MojoHandle* handles, uint32_t num_handles); 99 void RestoreBusyHandles(const MojoHandle* handles, uint32_t num_handles);
100 100
101 private: 101 private:
102 friend bool internal::ShutdownCheckNoLeaks(Core*); 102 friend bool internal::ShutdownCheckNoLeaks(Core*);
103 103
104 // The |busy| member is used only to deal with functions (in particular
105 // |Core::WriteMessage()|) that want to hold on to a dispatcher and later
106 // remove it from the handle table, without holding on to the handle table
107 // lock.
108 //
109 // For example, if |Core::WriteMessage()| is called with a handle to be sent,
110 // (under the handle table lock) it must first check that that handle is not
111 // busy (if it is busy, then it fails with |MOJO_RESULT_BUSY|) and then marks
112 // it as busy. To avoid deadlock, it should also try to acquire the locks for
113 // all the dispatchers for the handles that it is sending (and fail with
114 // |MOJO_RESULT_BUSY| if the attempt fails). At this point, it can release the
115 // handle table lock.
116 //
117 // If |Core::Close()| is simultaneously called on that handle, it too checks
118 // if the handle is marked busy. If it is, it fails (with |MOJO_RESULT_BUSY|).
119 // This prevents |Core::WriteMessage()| from sending a handle that has been
120 // closed (or learning about this too late).
104 struct Entry { 121 struct Entry {
105 Entry(); 122 Entry();
106 explicit Entry(const scoped_refptr<Dispatcher>& dispatcher); 123 explicit Entry(const scoped_refptr<Dispatcher>& dispatcher);
107 ~Entry(); 124 ~Entry();
108 125
109 scoped_refptr<Dispatcher> dispatcher; 126 scoped_refptr<Dispatcher> dispatcher;
110 bool busy; 127 bool busy;
111 }; 128 };
112 typedef base::hash_map<MojoHandle, Entry> HandleToEntryMap; 129 typedef base::hash_map<MojoHandle, Entry> HandleToEntryMap;
113 130
114 // Adds the given dispatcher to the handle table, not doing any size checks. 131 // Adds the given dispatcher to the handle table, not doing any size checks.
115 MojoHandle AddDispatcherNoSizeCheck( 132 MojoHandle AddDispatcherNoSizeCheck(
116 const scoped_refptr<Dispatcher>& dispatcher); 133 const scoped_refptr<Dispatcher>& dispatcher);
117 134
118 HandleToEntryMap handle_to_entry_map_; 135 HandleToEntryMap handle_to_entry_map_;
119 MojoHandle next_handle_; // Invariant: never |MOJO_HANDLE_INVALID|. 136 MojoHandle next_handle_; // Invariant: never |MOJO_HANDLE_INVALID|.
120 137
121 DISALLOW_COPY_AND_ASSIGN(HandleTable); 138 DISALLOW_COPY_AND_ASSIGN(HandleTable);
122 }; 139 };
123 140
124 } // namespace system 141 } // namespace system
125 } // namespace mojo 142 } // namespace mojo
126 143
127 #endif // MOJO_SYSTEM_HANDLE_TABLE_H_ 144 #endif // MOJO_SYSTEM_HANDLE_TABLE_H_
OLDNEW
« no previous file with comments | « mojo/system/core.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698