Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "content/browser/media/url_provision_fetcher.h" | 5 #include "content/browser/media/url_provision_fetcher.h" |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "content/public/browser/provision_fetcher_factory.h" | 8 #include "content/public/browser/provision_fetcher_factory.h" |
| 9 #include "media/base/bind_to_current_loop.h" | 9 #include "media/base/bind_to_current_loop.h" |
| 10 #include "net/traffic_annotation/network_traffic_annotation.h" | |
| 10 #include "net/url_request/url_fetcher.h" | 11 #include "net/url_request/url_fetcher.h" |
| 11 | 12 |
| 12 using net::URLFetcher; | 13 using net::URLFetcher; |
| 13 | 14 |
| 14 namespace content { | 15 namespace content { |
| 15 | 16 |
| 16 // Implementation of URLProvisionFetcher. | 17 // Implementation of URLProvisionFetcher. |
| 17 | 18 |
| 18 URLProvisionFetcher::URLProvisionFetcher( | 19 URLProvisionFetcher::URLProvisionFetcher( |
| 19 net::URLRequestContextGetter* context_getter) | 20 net::URLRequestContextGetter* context_getter) |
| 20 : context_getter_(context_getter) {} | 21 : context_getter_(context_getter) {} |
| 21 | 22 |
| 22 URLProvisionFetcher::~URLProvisionFetcher() {} | 23 URLProvisionFetcher::~URLProvisionFetcher() {} |
| 23 | 24 |
| 24 void URLProvisionFetcher::Retrieve( | 25 void URLProvisionFetcher::Retrieve( |
| 25 const std::string& default_url, | 26 const std::string& default_url, |
| 26 const std::string& request_data, | 27 const std::string& request_data, |
| 27 const media::ProvisionFetcher::ResponseCB& response_cb) { | 28 const media::ProvisionFetcher::ResponseCB& response_cb) { |
| 28 response_cb_ = response_cb; | 29 response_cb_ = response_cb; |
| 29 | 30 |
| 30 const std::string request_string = | 31 const std::string request_string = |
| 31 default_url + "&signedRequest=" + request_data; | 32 default_url + "&signedRequest=" + request_data; |
| 32 DVLOG(1) << __func__ << ": request:" << request_string; | 33 DVLOG(1) << __func__ << ": request:" << request_string; |
| 33 | 34 |
| 34 DCHECK(!request_); | 35 DCHECK(!request_); |
| 35 request_ = URLFetcher::Create(GURL(request_string), URLFetcher::POST, this); | 36 net::NetworkTrafficAnnotationTag traffic_annotation = |
| 37 net::DefineNetworkTrafficAnnotation("...", R"( | |
|
Tima Vaisburd
2017/03/07 18:56:43
I'm not familiar with NetworkTrafficAnnotation. Wh
Ramin Halavati
2017/03/08 08:52:34
Sorry I have not been very clear in the message. I
Tima Vaisburd
2017/03/09 00:16:35
Thank you!
semantics {
sender: "ProvisionFetch
Ramin Halavati
2017/03/09 06:28:47
Done.
| |
| 38 semantics { | |
| 39 sender: "..." | |
| 40 description: "..." | |
| 41 trigger: "..." | |
| 42 data: "..." | |
| 43 destination: WEBSITE/GOOGLE_OWNED_SERVICE/OTHER | |
| 44 } | |
| 45 policy { | |
| 46 cookies_allowed: false/true | |
| 47 cookies_store: "..." | |
| 48 setting: "..." | |
| 49 policy { | |
| 50 [POLICY_NAME] { | |
| 51 policy_options {mode: MANDATORY/RECOMMENDED/UNSET} | |
| 52 value: ... | |
| 53 } | |
| 54 } | |
| 55 policy_exception_justification: "..." | |
| 56 })"); | |
| 57 request_ = URLFetcher::Create(GURL(request_string), URLFetcher::POST, this, | |
| 58 traffic_annotation); | |
|
Tima Vaisburd
2017/03/07 18:56:43
I would create another helper method like
net::
Ramin Halavati
2017/03/08 08:52:34
We process this text using a clang tool that extra
Tima Vaisburd
2017/03/09 00:16:35
I think it would be better to leave it the way it
Ramin Halavati
2017/03/09 06:28:46
Done.
| |
| 36 | 59 |
| 37 // SetUploadData is mandatory even if we are not uploading anything. | 60 // SetUploadData is mandatory even if we are not uploading anything. |
| 38 request_->SetUploadData("", ""); | 61 request_->SetUploadData("", ""); |
| 39 request_->AddExtraRequestHeader("User-Agent: Widevine CDM v1.0"); | 62 request_->AddExtraRequestHeader("User-Agent: Widevine CDM v1.0"); |
| 40 request_->AddExtraRequestHeader("Content-Type: application/json"); | 63 request_->AddExtraRequestHeader("Content-Type: application/json"); |
| 41 | 64 |
| 42 DCHECK(context_getter_); | 65 DCHECK(context_getter_); |
| 43 request_->SetRequestContext(context_getter_); | 66 request_->SetRequestContext(context_getter_); |
| 44 | 67 |
| 45 request_->Start(); | 68 request_->Start(); |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 68 | 91 |
| 69 // Implementation of content public method CreateProvisionFetcher(). | 92 // Implementation of content public method CreateProvisionFetcher(). |
| 70 | 93 |
| 71 std::unique_ptr<media::ProvisionFetcher> CreateProvisionFetcher( | 94 std::unique_ptr<media::ProvisionFetcher> CreateProvisionFetcher( |
| 72 net::URLRequestContextGetter* context_getter) { | 95 net::URLRequestContextGetter* context_getter) { |
| 73 DCHECK(context_getter); | 96 DCHECK(context_getter); |
| 74 return base::MakeUnique<URLProvisionFetcher>(context_getter); | 97 return base::MakeUnique<URLProvisionFetcher>(context_getter); |
| 75 } | 98 } |
| 76 | 99 |
| 77 } // namespace content | 100 } // namespace content |
| OLD | NEW |