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

Side by Side Diff: jingle/glue/thread_wrapper.h

Issue 2037873003: Roll WebRTC 13098:13104 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Roll WebRTC Created 4 years, 6 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 | « DEPS ('k') | jingle/glue/thread_wrapper.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 JINGLE_GLUE_THREAD_WRAPPER_H_ 5 #ifndef JINGLE_GLUE_THREAD_WRAPPER_H_
6 #define JINGLE_GLUE_THREAD_WRAPPER_H_ 6 #define JINGLE_GLUE_THREAD_WRAPPER_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <list> 10 #include <list>
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 // synchronously to another thread using Send() method. Set to false 54 // synchronously to another thread using Send() method. Set to false
55 // by default to avoid potential jankiness when Send() used on 55 // by default to avoid potential jankiness when Send() used on
56 // renderer thread. It should be set explicitly for threads that 56 // renderer thread. It should be set explicitly for threads that
57 // need to call Send() for other threads. 57 // need to call Send() for other threads.
58 void set_send_allowed(bool allowed) { send_allowed_ = allowed; } 58 void set_send_allowed(bool allowed) { send_allowed_ = allowed; }
59 59
60 // MessageLoop::DestructionObserver implementation. 60 // MessageLoop::DestructionObserver implementation.
61 void WillDestroyCurrentMessageLoop() override; 61 void WillDestroyCurrentMessageLoop() override;
62 62
63 // rtc::MessageQueue overrides. 63 // rtc::MessageQueue overrides.
64 void Post(rtc::MessageHandler* phandler, 64 void Post(const rtc::Location& posted_from,
65 rtc::MessageHandler* phandler,
65 uint32_t id, 66 uint32_t id,
66 rtc::MessageData* pdata, 67 rtc::MessageData* pdata,
67 bool time_sensitive) override; 68 bool time_sensitive) override;
68 void PostDelayed(int delay_ms, 69 void PostDelayed(const rtc::Location& posted_from,
70 int delay_ms,
69 rtc::MessageHandler* handler, 71 rtc::MessageHandler* handler,
70 uint32_t id, 72 uint32_t id,
71 rtc::MessageData* data) override; 73 rtc::MessageData* data) override;
72 void Clear(rtc::MessageHandler* handler, 74 void Clear(rtc::MessageHandler* handler,
73 uint32_t id, 75 uint32_t id,
74 rtc::MessageList* removed) override; 76 rtc::MessageList* removed) override;
75 void Send(rtc::MessageHandler* handler, 77 void Dispatch(rtc::Message* message) override;
78 void Send(const rtc::Location& posted_from,
79 rtc::MessageHandler* handler,
76 uint32_t id, 80 uint32_t id,
77 rtc::MessageData* data) override; 81 rtc::MessageData* data) override;
78 82
79 // Following methods are not supported.They are overriden just to 83 // Following methods are not supported.They are overriden just to
80 // ensure that they are not called (each of them contain NOTREACHED 84 // ensure that they are not called (each of them contain NOTREACHED
81 // in the body). Some of this methods can be implemented if it 85 // in the body). Some of this methods can be implemented if it
82 // becomes neccessary to use libjingle code that calls them. 86 // becomes neccessary to use libjingle code that calls them.
83 void Quit() override; 87 void Quit() override;
84 bool IsQuitting() override; 88 bool IsQuitting() override;
85 void Restart() override; 89 void Restart() override;
86 bool Get(rtc::Message* message, int delay_ms, bool process_io) override; 90 bool Get(rtc::Message* message, int delay_ms, bool process_io) override;
87 bool Peek(rtc::Message* message, int delay_ms) override; 91 bool Peek(rtc::Message* message, int delay_ms) override;
88 void PostAt(uint32_t timestamp, 92 void PostAt(const rtc::Location& posted_from,
93 uint32_t timestamp,
89 rtc::MessageHandler* handler, 94 rtc::MessageHandler* handler,
90 uint32_t id, 95 uint32_t id,
91 rtc::MessageData* data) override; 96 rtc::MessageData* data) override;
92 void Dispatch(rtc::Message* message) override;
93 void ReceiveSends() override; 97 void ReceiveSends() override;
94 int GetDelay() override; 98 int GetDelay() override;
95 99
96 // rtc::Thread overrides. 100 // rtc::Thread overrides.
97 void Stop() override; 101 void Stop() override;
98 void Run() override; 102 void Run() override;
99 103
100 private: 104 private:
101 typedef std::map<int, rtc::Message> MessagesQueue; 105 typedef std::map<int, rtc::Message> MessagesQueue;
102 struct PendingSend; 106 struct PendingSend;
103 107
104 explicit JingleThreadWrapper( 108 explicit JingleThreadWrapper(
105 scoped_refptr<base::SingleThreadTaskRunner> task_runner); 109 scoped_refptr<base::SingleThreadTaskRunner> task_runner);
106 110
107 void PostTaskInternal(int delay_ms, 111 void PostTaskInternal(const rtc::Location& posted_from,
112 int delay_ms,
108 rtc::MessageHandler* handler, 113 rtc::MessageHandler* handler,
109 uint32_t message_id, 114 uint32_t message_id,
110 rtc::MessageData* data); 115 rtc::MessageData* data);
111 void RunTask(int task_id); 116 void RunTask(int task_id);
112 void ProcessPendingSends(); 117 void ProcessPendingSends();
113 118
114 // Task runner used to execute messages posted on this thread. 119 // Task runner used to execute messages posted on this thread.
115 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 120 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
116 121
117 bool send_allowed_; 122 bool send_allowed_;
118 123
119 // |lock_| must be locked when accessing |messages_|. 124 // |lock_| must be locked when accessing |messages_|.
120 base::Lock lock_; 125 base::Lock lock_;
121 int last_task_id_; 126 int last_task_id_;
122 MessagesQueue messages_; 127 MessagesQueue messages_;
123 std::list<PendingSend*> pending_send_messages_; 128 std::list<PendingSend*> pending_send_messages_;
124 base::WaitableEvent pending_send_event_; 129 base::WaitableEvent pending_send_event_;
125 130
126 base::WeakPtr<JingleThreadWrapper> weak_ptr_; 131 base::WeakPtr<JingleThreadWrapper> weak_ptr_;
127 base::WeakPtrFactory<JingleThreadWrapper> weak_ptr_factory_; 132 base::WeakPtrFactory<JingleThreadWrapper> weak_ptr_factory_;
128 133
129 DISALLOW_COPY_AND_ASSIGN(JingleThreadWrapper); 134 DISALLOW_COPY_AND_ASSIGN(JingleThreadWrapper);
130 }; 135 };
131 136
132 } // namespace jingle_glue 137 } // namespace jingle_glue
133 138
134 #endif // JINGLE_GLUE_THREAD_WRAPPER_H_ 139 #endif // JINGLE_GLUE_THREAD_WRAPPER_H_
OLDNEW
« no previous file with comments | « DEPS ('k') | jingle/glue/thread_wrapper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698