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

Side by Side Diff: media/mojo/services/mojo_cdm_service_context.cc

Issue 1230313010: media: Add ServiceFactory mojo interface and implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase only Created 5 years, 5 months 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/mojo/services/mojo_cdm_service_context.h" 5 #include "media/mojo/services/mojo_cdm_service_context.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "media/mojo/services/mojo_cdm_service.h"
9 10
10 namespace media { 11 namespace media {
11 12
12 MojoCdmServiceContext::MojoCdmServiceContext() { 13 MojoCdmServiceContext::MojoCdmServiceContext() : weak_ptr_factory_(this) {}
14
15 MojoCdmServiceContext::~MojoCdmServiceContext() {
13 } 16 }
14 17
15 MojoCdmServiceContext::~MojoCdmServiceContext() { 18 base::WeakPtr<MojoCdmServiceContext> MojoCdmServiceContext::GetWeakPtr() {
19 return weak_ptr_factory_.GetWeakPtr();
16 } 20 }
17 21
18 void MojoCdmServiceContext::RegisterCdm(int cdm_id, 22 void MojoCdmServiceContext::RegisterCdm(int cdm_id,
19 MojoCdmService* cdm_service) { 23 MojoCdmService* cdm_service) {
20 DCHECK(!cdm_services_.count(cdm_id)); 24 DCHECK(!cdm_services_.count(cdm_id));
21 DCHECK(cdm_service); 25 DCHECK(cdm_service);
22 cdm_services_[cdm_id] = cdm_service; 26 cdm_services_[cdm_id] = cdm_service;
23 } 27 }
24 28
25 void MojoCdmServiceContext::UnregisterCdm(int cdm_id) { 29 void MojoCdmServiceContext::UnregisterCdm(int cdm_id) {
26 DCHECK(cdm_services_.count(cdm_id)); 30 DCHECK(cdm_services_.count(cdm_id));
27 cdm_services_.erase(cdm_id); 31 cdm_services_.erase(cdm_id);
28 } 32 }
29 33
30 CdmContext* MojoCdmServiceContext::GetCdmContext(int32_t cdm_id) { 34 CdmContext* MojoCdmServiceContext::GetCdmContext(int32_t cdm_id) {
31 auto cdm_service = cdm_services_.find(cdm_id); 35 auto cdm_service = cdm_services_.find(cdm_id);
32 if (cdm_service == cdm_services_.end()) { 36 if (cdm_service == cdm_services_.end()) {
33 LOG(ERROR) << "CDM context not found: " << cdm_id; 37 LOG(ERROR) << "CDM context not found: " << cdm_id;
34 return nullptr; 38 return nullptr;
35 } 39 }
36 40
37 return cdm_service->second->GetCdmContext(); 41 return cdm_service->second->GetCdmContext();
38 } 42 }
39 43
40 } // namespace media 44 } // namespace media
OLDNEW
« no previous file with comments | « media/mojo/services/mojo_cdm_service_context.h ('k') | media/mojo/services/mojo_media_application.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698