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

Side by Side Diff: content/browser/media/android/url_provision_fetcher.cc

Issue 1427183002: Move MediaDrmBridge provision communication to native side. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: For on-demand provisioning the fetcher is created in content/ and depends on the renderer. Created 5 years, 1 month 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "content/browser/media/android/url_provision_fetcher.h"
6
7 #include <sstream>
8
9 #include "content/public/browser/android/cdm_provision_fetcher.h"
10 #include "media/base/bind_to_current_loop.h"
11 #include "net/url_request/url_fetcher.h"
12
13 namespace content {
14
15 using net::URLFetcher;
16
17 URLProvisionFetcher::URLProvisionFetcher(net::URLRequestContextGetter* context)
18 : url_request_context_(context) {}
19
20 URLProvisionFetcher::~URLProvisionFetcher() {}
21
22 void URLProvisionFetcher::Retrieve(
23 const std::string& default_url,
24 const std::string& request_data,
25 const media::ProvisionFetcher::ResponseCB& response_cb) {
xhwang 2015/11/06 23:08:18 I suppose we can't make multiple requests? How abo
Tima Vaisburd 2015/11/11 03:03:33 Done.
26 response_cb_ = media::BindToCurrentLoop(response_cb);
xhwang 2015/11/06 23:08:18 Will Retrieve() and OnURLFetchComplete() be called
27
28 std::ostringstream os;
29 os << default_url << "&signedRequest=" << request_data;
xhwang 2015/11/06 23:08:18 Is this "signedRequest" part documented anywhere?
Tima Vaisburd 2015/11/11 03:03:33 This is what the java code did. The only doc I fou
xhwang 2015/11/11 09:53:21 Yeah, it's like magic... +qinmin, do you remember
30 DVLOG(1) << __FUNCTION__ << ": request:" << os.str();
31
32 request_ = URLFetcher::Create(GURL(os.str()), URLFetcher::POST, this);
xhwang 2015/11/06 23:08:18 sorry for the bikeshedding... I think we use stre
Tima Vaisburd 2015/11/11 03:03:33 Yes, we can. I think it would be nice to know wha
xhwang 2015/11/11 09:53:20 I won't worry about performance here, it's really
Tima Vaisburd 2015/11/11 23:26:35 My stubbornness won't stretch pass this point. Don
33
34 // SetUploadData is mandatory even if we are not uploading anything.
35 request_->SetUploadData("", "");
36 request_->AddExtraRequestHeader("User-Agent: Widevine CDM v1.0");
37 request_->AddExtraRequestHeader("Content-Type: application/json");
38
39 DCHECK(url_request_context_);
40 request_->SetRequestContext(url_request_context_);
41
42 request_->Start();
43 }
44
45 void URLProvisionFetcher::OnURLFetchComplete(const net::URLFetcher* source) {
46 DCHECK(source);
47
48 int response_code = source->GetResponseCode();
49 DVLOG(1) << __FUNCTION__ << ": response code:" << source->GetResponseCode();
50
51 std::string response;
52 bool success = false;
53 if (response_code == 200) {
54 success = source->GetResponseAsString(&response);
55 if (!success)
56 DVLOG(1) << __FUNCTION__ << ": GetResponseAsString() failed";
xhwang 2015/11/06 23:08:18 nit: Use DVLOG_IF
Tima Vaisburd 2015/11/11 03:03:33 Done.
57 } else {
58 DVLOG(1) << "CDM provision: server returned error code " << response_code;
59 }
60
61 request_.reset();
62
63 DCHECK(!response_cb_.is_null());
64 response_cb_.Run(success, response);
65 }
66
67 // CDMProvisionFetcher implementation.
68
69 // static
70 scoped_ptr<media::ProvisionFetcher> CDMProvisionFetcher::CreateWithURLContext(
xhwang 2015/11/06 23:08:18 Why do we need CDMProvisionFetcher?
Tima Vaisburd 2015/11/11 03:03:33 According to the current dependency rules chrome/
xhwang 2015/11/11 09:53:20 Oh I see. I missed that. No we should not change
Tima Vaisburd 2015/11/11 23:26:35 Yes, created a factory function CreateProvisionFet
71 net::URLRequestContextGetter* context) {
72 return scoped_ptr<media::ProvisionFetcher>(new URLProvisionFetcher(context));
73 }
74
75 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698