Allow the externalfile scheme to be whitelisted as an allowed scheme for component...
[chromium-blink-merge.git] / media / blink / new_session_cdm_result_promise.h
blobc4b657da122ff44f4c8bb9857b8753ed6d1b8f79
1 // Copyright 2014 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.
5 #ifndef MEDIA_BLINK_NEW_SESSION_CDM_RESULT_PROMISE_H_
6 #define MEDIA_BLINK_NEW_SESSION_CDM_RESULT_PROMISE_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "media/base/cdm_promise.h"
12 #include "media/base/media_export.h"
13 #include "media/base/media_keys.h"
14 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleResult.h"
16 namespace media {
18 typedef base::Callback<blink::WebContentDecryptionModuleResult::SessionStatus(
19 const std::string& session_id)> SessionInitializedCB;
21 // Special class for resolving a new session promise. Resolving a new session
22 // promise returns the session ID (as a string), but the blink promise needs
23 // to get passed a SessionStatus. This class converts the session id to a
24 // SessionStatus by calling |new_session_created_cb|.
25 class MEDIA_EXPORT NewSessionCdmResultPromise
26 : public CdmPromiseTemplate<std::string> {
27 public:
28 NewSessionCdmResultPromise(
29 const blink::WebContentDecryptionModuleResult& result,
30 const std::string& uma_name,
31 const SessionInitializedCB& new_session_created_cb);
32 ~NewSessionCdmResultPromise() override;
34 // CdmPromiseTemplate<T> implementation.
35 void resolve(const std::string& session_id) override;
36 void reject(MediaKeys::Exception exception_code,
37 uint32 system_code,
38 const std::string& error_message) override;
40 private:
41 blink::WebContentDecryptionModuleResult web_cdm_result_;
43 // UMA name to report result to.
44 std::string uma_name_;
46 // Called on resolve() to convert the session ID into a SessionStatus to
47 // be reported to blink.
48 SessionInitializedCB new_session_created_cb_;
50 DISALLOW_COPY_AND_ASSIGN(NewSessionCdmResultPromise);
53 } // namespace media
55 #endif // MEDIA_BLINK_NEW_SESSION_CDM_RESULT_PROMISE_H_