Remove use of deprecated SkImage::getTexture() from gl_renderer.cc
[chromium-blink-merge.git] / media / blink / webcontentdecryptionmodulesession_impl.h
blob2f00ff5b3687be9763c28b05c57520cb9bdbffb6
1 // Copyright 2013 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_WEBCONTENTDECRYPTIONMODULESESSION_IMPL_H_
6 #define MEDIA_BLINK_WEBCONTENTDECRYPTIONMODULESESSION_IMPL_H_
8 #include <string>
9 #include <vector>
11 #include "base/basictypes.h"
12 #include "base/callback.h"
13 #include "base/memory/ref_counted.h"
14 #include "base/memory/weak_ptr.h"
15 #include "media/base/media_keys.h"
16 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleSession.h"
17 #include "third_party/WebKit/public/platform/WebString.h"
19 namespace media {
21 class CdmSessionAdapter;
22 class MediaKeys;
24 class WebContentDecryptionModuleSessionImpl
25 : public blink::WebContentDecryptionModuleSession {
26 public:
27 WebContentDecryptionModuleSessionImpl(
28 const scoped_refptr<CdmSessionAdapter>& adapter);
29 virtual ~WebContentDecryptionModuleSessionImpl();
31 // blink::WebContentDecryptionModuleSession implementation.
32 virtual void setClientInterface(Client* client);
33 virtual blink::WebString sessionId() const;
35 virtual void initializeNewSession(
36 blink::WebEncryptedMediaInitDataType init_data_type,
37 const unsigned char* initData,
38 size_t initDataLength,
39 blink::WebEncryptedMediaSessionType session_type,
40 blink::WebContentDecryptionModuleResult result);
41 virtual void load(const blink::WebString& session_id,
42 blink::WebContentDecryptionModuleResult result);
43 virtual void update(const uint8* response,
44 size_t response_length,
45 blink::WebContentDecryptionModuleResult result);
46 virtual void close(blink::WebContentDecryptionModuleResult result);
47 virtual void remove(blink::WebContentDecryptionModuleResult result);
49 // Callbacks.
50 void OnSessionMessage(MediaKeys::MessageType message_type,
51 const std::vector<uint8>& message);
52 void OnSessionKeysChange(bool has_additional_usable_key,
53 CdmKeysInfo keys_info);
54 void OnSessionExpirationUpdate(const base::Time& new_expiry_time);
55 void OnSessionClosed();
57 private:
58 // Called when a new session is created.
59 blink::WebContentDecryptionModuleResult::SessionStatus OnSessionInitialized(
60 const std::string& session_id);
62 scoped_refptr<CdmSessionAdapter> adapter_;
64 // Non-owned pointer.
65 Client* client_;
67 // Session ID is the app visible ID for this session generated by the CDM.
68 // This value is not set until the CDM resolves the initializeNewSession()
69 // promise.
70 std::string session_id_;
72 // Don't pass more than 1 close() event to blink::
73 // TODO(jrummell): Remove this once blink tests handle close() promise and
74 // closed() event.
75 bool is_closed_;
77 // Since promises will live until they are fired, use a weak reference when
78 // creating a promise in case this class disappears before the promise
79 // actually fires.
80 base::WeakPtrFactory<WebContentDecryptionModuleSessionImpl> weak_ptr_factory_;
82 DISALLOW_COPY_AND_ASSIGN(WebContentDecryptionModuleSessionImpl);
85 } // namespace media
87 #endif // MEDIA_BLINK_WEBCONTENTDECRYPTIONMODULESESSION_IMPL_H_