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

Side by Side Diff: remoting/jingle_glue/jingle_thread.cc

Issue 2690003: Copy the (early prototype of) remoting in Chrome into the public tree.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 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 | Annotate | Revision Log
« no previous file with comments | « remoting/jingle_glue/jingle_thread.h ('k') | remoting/jingle_glue/jingle_thread_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "remoting/jingle_glue/jingle_thread.h"
6
7 #include "base/logging.h"
8 #include "base/message_loop.h"
9 #include "talk/base/ssladapter.h"
10
11 namespace remoting {
12
13 const int kRunTasksMessageId = 1;
14
15 TaskPump::TaskPump() {
16 }
17
18 void TaskPump::WakeTasks() {
19 talk_base::Thread::Current()->Post(this);
20 }
21
22 int64 TaskPump::CurrentTime() {
23 return static_cast<int64>(talk_base::Time());
24 }
25
26 void TaskPump::OnMessage(talk_base::Message* pmsg) {
27 RunTasks();
28 }
29
30 JingleThread::JingleThread()
31 : message_loop_(NULL),
32 task_pump_(NULL),
33 started_event_(true, false) { }
34
35 JingleThread::~JingleThread() { }
36
37 void JingleThread::Start() {
38 Thread::Start();
39 started_event_.Wait();
40 }
41
42 void JingleThread::Run() {
43 LOG(INFO) << "Started Jingle thread.";
44
45 MessageLoopForIO message_loop;
46 message_loop_ = &message_loop;
47
48 TaskPump task_pump;
49 task_pump_ = &task_pump;
50
51 // Signal after we've initialized |message_loop_| and |task_pump_|.
52 started_event_.Signal();
53
54 Post(this, kRunTasksMessageId);
55
56 Thread::Run();
57
58 message_loop.RunAllPending();
59
60 task_pump_ = NULL;
61 message_loop_ = NULL;
62
63 LOG(INFO) << "Jingle thread finished.";
64 }
65
66 // This method is called every 20ms to process tasks from |message_loop_|
67 // on this thread.
68 // TODO(sergeyu): Remove it when JingleThread moved to Chromium's base::Thread.
69 void JingleThread::PumpAuxiliaryLoops() {
70 MessageLoop::current()->RunAllPending();
71
72 // Schedule next execution 20ms from now.
73 PostDelayed(20, this, kRunTasksMessageId);
74 }
75
76 void JingleThread::OnMessage(talk_base::Message* msg) {
77 PumpAuxiliaryLoops();
78 }
79
80 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/jingle_glue/jingle_thread.h ('k') | remoting/jingle_glue/jingle_thread_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698