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

Side by Side Diff: media/base/android/android_cdm_factory.cc

Issue 1427183002: Move MediaDrmBridge provision communication to native side. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: AndroidCdmFactory use a fetcher factory instead of a fetcher; addressed more comments 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
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 "media/base/android/android_cdm_factory.h" 5 #include "media/base/android/android_cdm_factory.h"
6 6
7 #include "base/strings/string_number_conversions.h" 7 #include "base/strings/string_number_conversions.h"
8 #include "media/base/android/media_drm_bridge.h" 8 #include "media/base/android/media_drm_bridge.h"
9 #include "media/base/android/provision_fetcher.h"
9 #include "media/base/bind_to_current_loop.h" 10 #include "media/base/bind_to_current_loop.h"
10 #include "media/base/cdm_config.h" 11 #include "media/base/cdm_config.h"
11 #include "media/base/key_systems.h" 12 #include "media/base/key_systems.h"
12 #include "third_party/widevine/cdm/widevine_cdm_common.h" 13 #include "third_party/widevine/cdm/widevine_cdm_common.h"
13 #include "url/gurl.h" 14 #include "url/gurl.h"
14 15
15 namespace media { 16 namespace media {
16 17
17 AndroidCdmFactory::AndroidCdmFactory() {} 18 AndroidCdmFactory::AndroidCdmFactory(
19 scoped_ptr<ProvisionFetcherFactory> fetcher_factory)
20 : fetcher_factory_(fetcher_factory.Pass()) {}
18 21
19 AndroidCdmFactory::~AndroidCdmFactory() {} 22 AndroidCdmFactory::~AndroidCdmFactory() {}
20 23
21 void AndroidCdmFactory::Create( 24 void AndroidCdmFactory::Create(
22 const std::string& key_system, 25 const std::string& key_system,
23 const GURL& security_origin, 26 const GURL& security_origin,
24 const CdmConfig& cdm_config, 27 const CdmConfig& cdm_config,
25 const SessionMessageCB& session_message_cb, 28 const SessionMessageCB& session_message_cb,
26 const SessionClosedCB& session_closed_cb, 29 const SessionClosedCB& session_closed_cb,
27 const LegacySessionErrorCB& legacy_session_error_cb, 30 const LegacySessionErrorCB& legacy_session_error_cb,
(...skipping 10 matching lines...) Expand all
38 41
39 std::string error_message; 42 std::string error_message;
40 43
41 if (!MediaDrmBridge::IsKeySystemSupported(key_system)) { 44 if (!MediaDrmBridge::IsKeySystemSupported(key_system)) {
42 error_message = "Key system not supported unexpectedly: " + key_system; 45 error_message = "Key system not supported unexpectedly: " + key_system;
43 NOTREACHED() << error_message; 46 NOTREACHED() << error_message;
44 bound_cdm_created_cb.Run(nullptr, error_message); 47 bound_cdm_created_cb.Run(nullptr, error_message);
45 return; 48 return;
46 } 49 }
47 50
51 DCHECK(fetcher_factory_);
52 scoped_ptr<ProvisionFetcher> fetcher = fetcher_factory_->CreateFetcher();
53
48 scoped_refptr<MediaDrmBridge> cdm( 54 scoped_refptr<MediaDrmBridge> cdm(
49 MediaDrmBridge::Create(key_system, session_message_cb, session_closed_cb, 55 MediaDrmBridge::Create(key_system, fetcher.Pass(),
xhwang 2015/11/12 22:27:03 nit: you can pass fetcher_factory_->CreateFetcher(
Tima Vaisburd 2015/11/13 03:13:10 Used the callback method instead the factory.
56 session_message_cb, session_closed_cb,
50 legacy_session_error_cb, session_keys_change_cb, 57 legacy_session_error_cb, session_keys_change_cb,
51 session_expiration_update_cb)); 58 session_expiration_update_cb));
52 if (!cdm) { 59 if (!cdm) {
53 error_message = "MediaDrmBridge cannot be created for " + key_system; 60 error_message = "MediaDrmBridge cannot be created for " + key_system;
54 NOTREACHED() << error_message; 61 NOTREACHED() << error_message;
55 bound_cdm_created_cb.Run(nullptr, error_message); 62 bound_cdm_created_cb.Run(nullptr, error_message);
56 return; 63 return;
57 } 64 }
58 65
59 if (key_system == kWidevineKeySystem) { 66 if (key_system == kWidevineKeySystem) {
(...skipping 16 matching lines...) Expand all
76 NOTREACHED() << error_message; 83 NOTREACHED() << error_message;
77 bound_cdm_created_cb.Run(nullptr, error_message); 84 bound_cdm_created_cb.Run(nullptr, error_message);
78 return; 85 return;
79 } 86 }
80 87
81 // Success! 88 // Success!
82 bound_cdm_created_cb.Run(cdm, ""); 89 bound_cdm_created_cb.Run(cdm, "");
83 } 90 }
84 91
85 } // namespace media 92 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698