IndexedDBFactory now ForceCloses databases.
[chromium-blink-merge.git] / content / renderer / media / webcontentdecryptionmodulesession_impl.h
blobc614ee3a978505a966df476e7c1a58b9c2239e84
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 CONTENT_RENDERER_MEDIA_WEBCONTENTDECRYPTIONMODULESESSION_IMPL_H_
6 #define CONTENT_RENDERER_MEDIA_WEBCONTENTDECRYPTIONMODULESESSION_IMPL_H_
8 #include <string>
9 #include <vector>
11 #include "base/basictypes.h"
12 #include "base/callback.h"
13 #include "media/base/media_keys.h"
14 #include "third_party/WebKit/public/platform/WebContentDecryptionModuleSession.h"
15 #include "third_party/WebKit/public/platform/WebString.h"
17 namespace media {
18 class MediaKeys;
21 namespace content {
23 class WebContentDecryptionModuleSessionImpl
24 : public blink::WebContentDecryptionModuleSession {
25 public:
26 typedef base::Callback<void(uint32 session_id)> SessionClosedCB;
28 WebContentDecryptionModuleSessionImpl(
29 uint32 session_id,
30 media::MediaKeys* media_keys,
31 Client* client,
32 const SessionClosedCB& session_closed_cb);
33 virtual ~WebContentDecryptionModuleSessionImpl();
35 // blink::WebContentDecryptionModuleSession implementation.
36 virtual blink::WebString sessionId() const;
37 virtual void initializeNewSession(const blink::WebString& mime_type,
38 const uint8* init_data,
39 size_t init_data_length);
40 virtual void update(const uint8* response, size_t response_length);
41 virtual void release();
43 // TODO(xhwang): Drop generateKeyRequest() and close() after blink side is
44 // updated.
45 virtual void generateKeyRequest(const blink::WebString& mime_type,
46 const uint8* init_data,
47 size_t init_data_length);
48 virtual void close();
50 // Callbacks.
51 void OnSessionCreated(const std::string& web_session_id);
52 void OnSessionMessage(const std::vector<uint8>& message,
53 const std::string& destination_url);
54 void OnSessionReady();
55 void OnSessionClosed();
56 void OnSessionError(media::MediaKeys::KeyError error_code, int system_code);
58 private:
59 // Non-owned pointers.
60 media::MediaKeys* media_keys_;
61 Client* client_;
63 SessionClosedCB session_closed_cb_;
65 // Web session ID is the app visible ID for this session generated by the CDM.
66 // This value is not set until the CDM calls OnSessionCreated().
67 blink::WebString web_session_id_;
69 // Session ID is used to uniquely track this object so that CDM callbacks
70 // can get routed to the correct object.
71 const uint32 session_id_;
73 DISALLOW_COPY_AND_ASSIGN(WebContentDecryptionModuleSessionImpl);
76 } // namespace content
78 #endif // CONTENT_RENDERER_MEDIA_WEBCONTENTDECRYPTIONMODULESESSION_IMPL_H_