OLD | NEW |
| (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/provision_fetcher_impl.h" | |
6 | |
7 #include "content/public/browser/android/provision_fetcher_factory.h" | |
8 #include "content/public/browser/browser_context.h" | |
9 #include "content/public/browser/render_frame_host.h" | |
10 #include "content/public/browser/render_process_host.h" | |
11 #include "content/public/browser/storage_partition.h" | |
12 #include "mojo/public/cpp/bindings/strong_binding.h" | |
13 #include "net/url_request/url_request_context_getter.h" | |
14 | |
15 namespace content { | |
16 | |
17 // static | |
18 void ProvisionFetcherImpl::Create( | |
19 RenderFrameHost* render_frame_host, | |
20 media::mojom::ProvisionFetcherRequest request) { | |
21 net::URLRequestContextGetter* context_getter = | |
22 BrowserContext::GetDefaultStoragePartition( | |
23 render_frame_host->GetProcess()->GetBrowserContext())-> | |
24 GetURLRequestContext(); | |
25 DCHECK(context_getter); | |
26 mojo::MakeStrongBinding(base::MakeUnique<ProvisionFetcherImpl>( | |
27 CreateProvisionFetcher(context_getter)), | |
28 std::move(request)); | |
29 } | |
30 | |
31 ProvisionFetcherImpl::ProvisionFetcherImpl( | |
32 std::unique_ptr<media::ProvisionFetcher> provision_fetcher) | |
33 : provision_fetcher_(std::move(provision_fetcher)), weak_factory_(this) { | |
34 DVLOG(1) << __FUNCTION__; | |
35 } | |
36 | |
37 ProvisionFetcherImpl::~ProvisionFetcherImpl() {} | |
38 | |
39 void ProvisionFetcherImpl::Retrieve(const std::string& default_url, | |
40 const std::string& request_data, | |
41 const RetrieveCallback& callback) { | |
42 DVLOG(1) << __FUNCTION__ << ": " << default_url; | |
43 provision_fetcher_->Retrieve( | |
44 default_url, request_data, | |
45 base::Bind(&ProvisionFetcherImpl::OnResponse, weak_factory_.GetWeakPtr(), | |
46 callback)); | |
47 } | |
48 | |
49 void ProvisionFetcherImpl::OnResponse(const RetrieveCallback& callback, | |
50 bool success, | |
51 const std::string& response) { | |
52 DVLOG(1) << __FUNCTION__ << ": " << success; | |
53 callback.Run(success, response); | |
54 } | |
55 | |
56 } // namespace content | |
OLD | NEW |