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

Side by Side Diff: mojo/edk/system/channel_manager.h

Issue 728613002: Make the embedder API use the ChannelManager. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: update comment Created 6 years, 1 month 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 | « mojo/edk/embedder/test_embedder.cc ('k') | mojo/edk/system/channel_manager.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 MOJO_EDK_SYSTEM_CHANNEL_MANAGER_H_ 5 #ifndef MOJO_EDK_SYSTEM_CHANNEL_MANAGER_H_
6 #define MOJO_EDK_SYSTEM_CHANNEL_MANAGER_H_ 6 #define MOJO_EDK_SYSTEM_CHANNEL_MANAGER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/containers/hash_tables.h" 10 #include "base/containers/hash_tables.h"
(...skipping 25 matching lines...) Expand all
36 // 36 //
37 // Note: This is currently a static method and thus may be called under 37 // Note: This is currently a static method and thus may be called under
38 // |lock_|. If this is ever made non-static (i.e., made specific to a given 38 // |lock_|. If this is ever made non-static (i.e., made specific to a given
39 // |ChannelManager|), those call sites may have to changed. 39 // |ChannelManager|), those call sites may have to changed.
40 static ChannelId GetChannelId(const Channel* channel) { 40 static ChannelId GetChannelId(const Channel* channel) {
41 return reinterpret_cast<ChannelId>(channel); 41 return reinterpret_cast<ChannelId>(channel);
42 } 42 }
43 43
44 // Adds |channel| to the set of |Channel|s managed by this |ChannelManager|; 44 // Adds |channel| to the set of |Channel|s managed by this |ChannelManager|;
45 // |channel_thread_task_runner| should be the task runner for |channel|'s 45 // |channel_thread_task_runner| should be the task runner for |channel|'s
46 // creation (a.k.a. I/O) thread. 46 // creation (a.k.a. I/O) thread. |channel| should either already be
47 // 47 // initialized. It should not be managed by any |ChannelManager| yet. Returns
48 // |channel| should either already be initialized or at least already have a 48 // the ID for the added channel.
49 // task posted to |channel_thread_task_runner| to initialize it. It should not
50 // be managed by any |ChannelManager| yet.
51 //
52 // Returns the ID for the added channel.
53 ChannelId AddChannel( 49 ChannelId AddChannel(
54 scoped_refptr<Channel> channel, 50 scoped_refptr<Channel> channel,
55 scoped_refptr<base::TaskRunner> channel_thread_task_runner); 51 scoped_refptr<base::TaskRunner> channel_thread_task_runner);
56 52
53 // Informs the channel manager (and thus channel) that it will be shutdown
54 // soon (by calling |ShutdownChannel()|). Calling this is optional (and may in
55 // fact be called multiple times) but it will suppress certain warnings (e.g.,
56 // for the channel being broken) and enable others (if messages are written to
57 // the channel).
58 void WillShutdownChannel(ChannelId channel_id);
59
57 // Shuts down the channel specified by the given ID. It is up to the caller to 60 // Shuts down the channel specified by the given ID. It is up to the caller to
58 // guarantee that this is only called once per channel (that was added using 61 // guarantee that this is only called once per channel (that was added using
59 // |AddChannel()|). 62 // |AddChannel()|). If called from the chanel's creation thread (i.e.,
63 // |base::MessageLoopProxy::current()| is the channel thread's |TaskRunner|),
64 // this will complete synchronously.
60 void ShutdownChannel(ChannelId channel_id); 65 void ShutdownChannel(ChannelId channel_id);
61 66
62 private: 67 private:
68 // Gets the |ChannelInfo| for the channel specified by the given ID. (This
69 // should *not* be called under lock.)
70 ChannelInfo GetChannelInfo(ChannelId channel_id);
71
63 // Note: |Channel| methods should not be called under |lock_|. 72 // Note: |Channel| methods should not be called under |lock_|.
64 base::Lock lock_; // Protects the members below. 73 base::Lock lock_; // Protects the members below.
65 74
66 base::hash_map<ChannelId, ChannelInfo> channel_infos_; 75 base::hash_map<ChannelId, ChannelInfo> channel_infos_;
67 76
68 DISALLOW_COPY_AND_ASSIGN(ChannelManager); 77 DISALLOW_COPY_AND_ASSIGN(ChannelManager);
69 }; 78 };
70 79
71 } // namespace system 80 } // namespace system
72 } // namespace mojo 81 } // namespace mojo
73 82
74 #endif // MOJO_EDK_SYSTEM_CHANNEL_MANAGER_H_ 83 #endif // MOJO_EDK_SYSTEM_CHANNEL_MANAGER_H_
OLDNEW
« no previous file with comments | « mojo/edk/embedder/test_embedder.cc ('k') | mojo/edk/system/channel_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698