OLD | NEW |
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 #include "chrome/browser/extensions/api/gcd_private/privet_v3_session.h" | 5 #include "chrome/browser/extensions/api/gcd_private/privet_v3_session.h" |
6 | 6 |
7 #include "base/base64.h" | 7 #include "base/base64.h" |
8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/location.h" | 10 #include "base/location.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/macros.h" | 12 #include "base/macros.h" |
13 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
14 #include "base/single_thread_task_runner.h" | 14 #include "base/single_thread_task_runner.h" |
15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
16 #include "base/threading/thread_task_runner_handle.h" | 16 #include "base/threading/thread_task_runner_handle.h" |
17 #include "chrome/browser/extensions/api/gcd_private/privet_v3_context_getter.h" | 17 #include "chrome/browser/extensions/api/gcd_private/privet_v3_context_getter.h" |
18 #include "crypto/hmac.h" | 18 #include "crypto/hmac.h" |
19 #include "crypto/p224_spake.h" | 19 #include "crypto/p224_spake.h" |
20 #include "net/base/load_flags.h" | 20 #include "net/base/load_flags.h" |
21 #include "net/http/http_response_headers.h" | 21 #include "net/http/http_response_headers.h" |
| 22 #include "net/traffic_annotation/network_traffic_annotation.h" |
22 #include "net/url_request/url_fetcher_delegate.h" | 23 #include "net/url_request/url_fetcher_delegate.h" |
23 #include "url/gurl.h" | 24 #include "url/gurl.h" |
24 | 25 |
25 namespace extensions { | 26 namespace extensions { |
26 | 27 |
27 namespace { | 28 namespace { |
28 | 29 |
29 const char kPrivetV3AuthTokenHeaderPrefix[] = "Authorization: "; | 30 const char kPrivetV3AuthTokenHeaderPrefix[] = "Authorization: "; |
30 | 31 |
31 const char kPrivetV3AuthAnonymous[] = "Privet anonymous"; | 32 const char kPrivetV3AuthAnonymous[] = "Privet anonymous"; |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 ReplyAndDestroyItself( | 165 ReplyAndDestroyItself( |
165 has_error ? Result::STATUS_DEVICEERROR : Result::STATUS_SUCCESS, *value); | 166 has_error ? Result::STATUS_DEVICEERROR : Result::STATUS_SUCCESS, *value); |
166 } | 167 } |
167 | 168 |
168 net::URLFetcher* PrivetV3Session::FetcherDelegate::CreateURLFetcher( | 169 net::URLFetcher* PrivetV3Session::FetcherDelegate::CreateURLFetcher( |
169 const GURL& url, | 170 const GURL& url, |
170 net::URLFetcher::RequestType request_type, | 171 net::URLFetcher::RequestType request_type, |
171 bool orphaned) { | 172 bool orphaned) { |
172 DCHECK(!url_fetcher_); | 173 DCHECK(!url_fetcher_); |
173 DCHECK(session_); | 174 DCHECK(session_); |
174 url_fetcher_ = net::URLFetcher::Create(url, request_type, this); | 175 url_fetcher_ = net::URLFetcher::Create(url, request_type, this, |
| 176 NO_TRAFFIC_ANNOTATION_YET); |
175 auto timeout_task = | 177 auto timeout_task = |
176 orphaned ? base::Bind(&FetcherDelegate::OnTimeout, base::Owned(this)) | 178 orphaned ? base::Bind(&FetcherDelegate::OnTimeout, base::Owned(this)) |
177 : base::Bind(&FetcherDelegate::OnTimeout, | 179 : base::Bind(&FetcherDelegate::OnTimeout, |
178 weak_ptr_factory_.GetWeakPtr()); | 180 weak_ptr_factory_.GetWeakPtr()); |
179 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 181 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
180 FROM_HERE, timeout_task, | 182 FROM_HERE, timeout_task, |
181 base::TimeDelta::FromSeconds(kUrlFetcherTimeoutSec)); | 183 base::TimeDelta::FromSeconds(kUrlFetcherTimeoutSec)); |
182 return url_fetcher_.get(); | 184 return url_fetcher_.get(); |
183 } | 185 } |
184 | 186 |
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 // Only session with pairing in process needs to be canceled. Paired sessions | 517 // Only session with pairing in process needs to be canceled. Paired sessions |
516 // (in https mode) does not need to be canceled. | 518 // (in https mode) does not need to be canceled. |
517 if (session_id_.empty() || use_https_) | 519 if (session_id_.empty() || use_https_) |
518 return; | 520 return; |
519 base::DictionaryValue input; | 521 base::DictionaryValue input; |
520 input.SetString(kPrivetV3KeySessionId, session_id_); | 522 input.SetString(kPrivetV3KeySessionId, session_id_); |
521 StartPostRequest(kPrivetV3PairingCancelPath, input, MessageCallback()); | 523 StartPostRequest(kPrivetV3PairingCancelPath, input, MessageCallback()); |
522 } | 524 } |
523 | 525 |
524 } // namespace extensions | 526 } // namespace extensions |
OLD | NEW |