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

Side by Side Diff: remoting/host/heartbeat_sender.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/host/heartbeat_sender.h ('k') | remoting/host/mock_objects.h » ('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/host/heartbeat_sender.h"
6
7 #include "base/logging.h"
8 #include "base/message_loop.h"
9 #include "remoting/base/constants.h"
10 #include "remoting/jingle_glue/iq_request.h"
11 #include "remoting/jingle_glue/jingle_client.h"
12 #include "remoting/jingle_glue/jingle_thread.h"
13 #include "talk/xmpp/constants.h"
14 #include "talk/xmllite/xmlelement.h"
15
16 namespace remoting {
17
18 namespace {
19 const char * const kChromotingNamespace = "google:remoting";
20 const buzz::QName kHeartbeatQuery(true, kChromotingNamespace, "heartbeat");
21 const buzz::QName kHostIdAttr(true, kChromotingNamespace, "hostid");
22
23 // TODO(sergeyu): Make this configurable by the cloud.
24 const int64 kHeartbeatPeriodMs = 5 * 60 * 1000; // 5 minutes.
25 }
26
27 HeartbeatSender::HeartbeatSender()
28 : started_(false) {
29 }
30
31 void HeartbeatSender::Start(JingleClient* jingle_client,
32 const std::string& host_id) {
33 DCHECK(jingle_client);
34 DCHECK(!started_);
35
36 started_ = true;
37
38 jingle_client_ = jingle_client;
39 host_id_ = host_id;
40
41 jingle_client_->message_loop()->PostTask(
42 FROM_HERE, NewRunnableMethod(this, &HeartbeatSender::DoStart));
43 }
44
45 void HeartbeatSender::DoStart() {
46 DCHECK(MessageLoop::current() == jingle_client_->message_loop());
47
48 request_.reset(new IqRequest(jingle_client_));
49
50 jingle_client_->message_loop()->PostTask(
51 FROM_HERE, NewRunnableMethod(this, &HeartbeatSender::DoSendStanza));
52 }
53
54 void HeartbeatSender::DoSendStanza() {
55 DCHECK(MessageLoop::current() == jingle_client_->message_loop());
56
57 LOG(INFO) << "Sending heartbeat stanza to " << kChromotingBotJid;
58
59 buzz::XmlElement* stanza = new buzz::XmlElement(kHeartbeatQuery);
60 stanza->AddAttr(kHostIdAttr, host_id_);
61 request_->SendIq(buzz::STR_SET, kChromotingBotJid, stanza);
62
63 // Schedule next heartbeat.
64 jingle_client_->message_loop()->PostDelayedTask(
65 FROM_HERE, NewRunnableMethod(this, &HeartbeatSender::DoSendStanza),
66 kHeartbeatPeriodMs);
67 }
68
69 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/heartbeat_sender.h ('k') | remoting/host/mock_objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698