Ignore title parameter for navigator.registerProtocolHandler
[chromium-blink-merge.git] / media / base / media_keys.h
bloba6ef64ceee0ea8d62a4ad8e29b1401351c766963
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_BASE_MEDIA_KEYS_H_
6 #define MEDIA_BASE_MEDIA_KEYS_H_
8 #include <string>
9 #include <vector>
11 #include "base/basictypes.h"
12 #include "base/callback.h"
13 #include "base/memory/scoped_ptr.h"
14 #include "media/base/media_export.h"
16 namespace media {
18 class Decryptor;
20 // Performs media key operations.
22 // All key operations are called on the renderer thread. Therefore, these calls
23 // should be fast and nonblocking; key events should be fired asynchronously.
24 class MEDIA_EXPORT MediaKeys {
25 public:
26 // Reported to UMA, so never reuse a value!
27 // Must be kept in sync with blink::WebMediaPlayerClient::MediaKeyErrorCode
28 // (enforced in webmediaplayer_impl.cc).
29 enum KeyError {
30 kUnknownError = 1,
31 kClientError,
32 // The commented v0.1b values below have never been used.
33 // kServiceError,
34 kOutputError = 4,
35 // kHardwareChangeError,
36 // kDomainError,
37 kMaxKeyError // Must be last and greater than any legit value.
40 const static uint32 kInvalidSessionId = 0;
42 MediaKeys();
43 virtual ~MediaKeys();
45 // Creates a session with the |content_type| and |init_data| provided.
46 // Returns true if a session is successfully created, false otherwise.
47 // Note: UpdateSession() and ReleaseSession() should only be called after
48 // SessionCreatedCB is fired.
49 // TODO(jrummell): Remove return value when prefixed API is removed.
50 // See http://crbug.com/342510
51 virtual bool CreateSession(uint32 session_id,
52 const std::string& content_type,
53 const uint8* init_data,
54 int init_data_length) = 0;
56 // Loads a session with the |web_session_id| provided.
57 // Note: UpdateSession() and ReleaseSession() should only be called after
58 // SessionCreatedCB is fired.
59 virtual void LoadSession(uint32 session_id,
60 const std::string& web_session_id) = 0;
62 // Updates a session specified by |session_id| with |response|.
63 virtual void UpdateSession(uint32 session_id,
64 const uint8* response,
65 int response_length) = 0;
67 // Releases the session specified by |session_id|.
68 virtual void ReleaseSession(uint32 session_id) = 0;
70 // Gets the Decryptor object associated with the MediaKeys. Returns NULL if
71 // no Decryptor object is associated. The returned object is only guaranteed
72 // to be valid during the MediaKeys' lifetime.
73 virtual Decryptor* GetDecryptor();
75 private:
76 DISALLOW_COPY_AND_ASSIGN(MediaKeys);
79 // Key event callbacks. See the spec for details:
80 // https://dvcs.w3.org/hg/html-media/raw-file/default/encrypted-media/encrypted-media.html#event-summary
81 typedef base::Callback<
82 void(uint32 session_id, const std::string& web_session_id)>
83 SessionCreatedCB;
85 typedef base::Callback<void(uint32 session_id,
86 const std::vector<uint8>& message,
87 const std::string& destination_url)>
88 SessionMessageCB;
90 typedef base::Callback<void(uint32 session_id)> SessionReadyCB;
92 typedef base::Callback<void(uint32 session_id)> SessionClosedCB;
94 typedef base::Callback<void(uint32 session_id,
95 media::MediaKeys::KeyError error_code,
96 uint32 system_code)> SessionErrorCB;
98 } // namespace media
100 #endif // MEDIA_BASE_MEDIA_KEYS_H_