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

Side by Side Diff: remoting/host/connection_block_checker.cc

Issue 10873050: [Chromoting] Hook up host talkgadget policy checks. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove extra comments/whitespace Created 8 years, 3 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "remoting/host/connection_block_checker.h"
6
7 #include "googleurl/src/gurl.h"
8 #include "net/url_request/url_fetcher.h"
9 #include "remoting/host/chromoting_host_context.h"
10 #include "remoting/host/constants.h"
11
12 namespace remoting {
13
14 const int kMaxConnectionBlockChecks = 5;
15
16 ConnectionBlockChecker::ConnectionBlockChecker(
17 ChromotingHostContext* context,
18 std::string talkgadget_prefix)
19 : context_(context),
20 talkgadget_prefix_(talkgadget_prefix),
21 status_(UNKNOWN),
22 check_pending_(false),
23 reconnect_attempts_(0) {
24 }
25
26 // This is called in response to the TalkGadget http request initiated from
27 // GetStatus().
28 void ConnectionBlockChecker::OnURLFetchComplete(const net::URLFetcher* source) {
29 check_pending_ = false;
30 int response = source->GetResponseCode();
31 if (response == 200) {
32 LOG(INFO) << "Successfully connected to talkgadget.";
33 status_ = ALLOW;
34 url_fetcher_.reset(NULL);
35 return;
36 }
37 if (response == 404 || reconnect_attempts_ > kMaxConnectionBlockChecks) {
Sergey Ulanov 2012/08/28 00:33:42 We may get 404 if there is a misbehaving proxy, so
garykac 2012/08/29 00:07:15 Done.
38 LOG(INFO) << "Unable to connect to talkgadget.";
39 status_ = DENY;
40 } else {
41 LOG(INFO) << "Failed to find talkgadget. Retrying...";
42 reconnect_attempts_++;
43 status_ = UNKNOWN;
44 }
45 }
46
47 ConnectionBlockChecker::Status ConnectionBlockChecker::GetStatus() {
Sergey Ulanov 2012/08/28 00:33:42 Here we check connection status only once when thi
garykac 2012/08/29 00:07:15 Done.
48 if (status_ == UNKNOWN && !check_pending_) {
49 std::string talkgadget_url("https://");
50 if (talkgadget_prefix_.empty()) {
51 talkgadget_url += kDefaultHostTalkGadgetPrefix;
52 } else {
53 talkgadget_url += talkgadget_prefix_;
54 }
55 talkgadget_url += kTalkGadgetUrl;
56 LOG(INFO) << "Verifying connection to " << talkgadget_url;
57 url_fetcher_.reset(net::URLFetcher::Create(GURL(talkgadget_url),
58 net::URLFetcher::GET, this));
59 url_fetcher_->SetRequestContext(context_->url_request_context_getter());
60 url_fetcher_->Start();
61 }
62 return status_;
63 }
64
65 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698