OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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 #ifndef CONTENT_BROWSER_MEDIA_ANDROID_MEDIA_RESOURCE_GETTER_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_MEDIA_ANDROID_MEDIA_RESOURCE_GETTER_IMPL_H_ |
6 #define CONTENT_BROWSER_MEDIA_ANDROID_MEDIA_RESOURCE_GETTER_IMPL_H_ | 6 #define CONTENT_BROWSER_MEDIA_ANDROID_MEDIA_RESOURCE_GETTER_IMPL_H_ |
7 | 7 |
8 #include <jni.h> | 8 #include <jni.h> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
13 #include "base/synchronization/waitable_event.h" | 13 #include "base/synchronization/waitable_event.h" |
14 #include "media/base/android/media_resource_getter.h" | 14 #include "media/base/android/media_resource_getter.h" |
| 15 #include "net/base/auth.h" |
15 #include "net/cookies/canonical_cookie.h" | 16 #include "net/cookies/canonical_cookie.h" |
16 | 17 |
17 namespace fileapi { | 18 namespace fileapi { |
18 class FileSystemContext; | 19 class FileSystemContext; |
19 } | 20 } |
20 | 21 |
21 namespace net { | 22 namespace net { |
22 class URLRequestContextGetter; | 23 class URLRequestContextGetter; |
23 } | 24 } |
24 | 25 |
25 namespace content { | 26 namespace content { |
26 | 27 |
27 class BrowserContext; | 28 class BrowserContext; |
28 class ResourceContext; | 29 class ResourceContext; |
29 | 30 |
30 // This class implements media::MediaResourceGetter to retrieve resources | 31 // This class implements media::MediaResourceGetter to retrieve resources |
31 // asynchronously on the UI thread. | 32 // asynchronously on the UI thread. |
32 class MediaResourceGetterImpl : public media::MediaResourceGetter { | 33 class MediaResourceGetterImpl : public media::MediaResourceGetter { |
33 public: | 34 public: |
34 // Construct a MediaResourceGetterImpl object. |browser_context| and | 35 // Construct a MediaResourceGetterImpl object. |browser_context| and |
35 // |render_process_id| are passed to retrieve the CookieStore. | 36 // |render_process_id| are passed to retrieve the CookieStore. |
36 // |file_system_context| are used to get the platform path. | 37 // |file_system_context| are used to get the platform path. |
37 MediaResourceGetterImpl(BrowserContext* browser_context, | 38 MediaResourceGetterImpl(BrowserContext* browser_context, |
38 fileapi::FileSystemContext* file_system_context, | 39 fileapi::FileSystemContext* file_system_context, |
39 int render_process_id, int render_frame_id); | 40 int render_process_id, int render_frame_id); |
40 virtual ~MediaResourceGetterImpl(); | 41 virtual ~MediaResourceGetterImpl(); |
41 | 42 |
42 // media::MediaResourceGetter implementation. | 43 // media::MediaResourceGetter implementation. |
43 // Must be called on the UI thread. | 44 // Must be called on the UI thread. |
44 virtual void GetCookies(const GURL& url, | 45 virtual void GetAuthCredentials( |
45 const GURL& first_party_for_cookies, | 46 const GURL& url, |
46 const GetCookieCB& callback) OVERRIDE; | 47 const GetAuthCredentialsCB& callback) OVERRIDE; |
| 48 virtual void GetCookies( |
| 49 const GURL& url, |
| 50 const GURL& first_party_for_cookies, |
| 51 const GetCookieCB& callback) OVERRIDE; |
47 virtual void GetPlatformPathFromURL( | 52 virtual void GetPlatformPathFromURL( |
48 const GURL& url, | 53 const GURL& url, |
49 const GetPlatformPathCB& callback) OVERRIDE; | 54 const GetPlatformPathCB& callback) OVERRIDE; |
50 virtual void ExtractMediaMetadata( | 55 virtual void ExtractMediaMetadata( |
51 const std::string& url, const std::string& cookies, | 56 const std::string& url, |
| 57 const std::string& cookies, |
52 const std::string& user_agent, | 58 const std::string& user_agent, |
53 const ExtractMediaMetadataCB& callback) OVERRIDE; | 59 const ExtractMediaMetadataCB& callback) OVERRIDE; |
54 | 60 |
55 static bool RegisterMediaResourceGetter(JNIEnv* env); | 61 static bool RegisterMediaResourceGetter(JNIEnv* env); |
56 | 62 |
57 private: | 63 private: |
| 64 // Called when GetAuthCredentials() finishes. |
| 65 void GetAuthCredentialsCallback( |
| 66 const GetAuthCredentialsCB& callback, |
| 67 const net::AuthCredentials& credentials); |
| 68 |
58 // Called when GetCookies() finishes. | 69 // Called when GetCookies() finishes. |
59 void GetCookiesCallback( | 70 void GetCookiesCallback( |
60 const GetCookieCB& callback, const std::string& cookies); | 71 const GetCookieCB& callback, const std::string& cookies); |
61 | 72 |
62 // Called when GetPlatformPathFromFileSystemURL() finishes. | 73 // Called when GetPlatformPathFromFileSystemURL() finishes. |
63 void GetPlatformPathCallback( | 74 void GetPlatformPathCallback( |
64 const GetPlatformPathCB& callback, const std::string& platform_path); | 75 const GetPlatformPathCB& callback, const std::string& platform_path); |
65 | 76 |
66 // BrowserContext to retrieve URLRequestContext and ResourceContext. | 77 // BrowserContext to retrieve URLRequestContext and ResourceContext. |
67 BrowserContext* browser_context_; | 78 BrowserContext* browser_context_; |
68 | 79 |
69 // FileSystemContext to be used on FILE thread. | 80 // FileSystemContext to be used on FILE thread. |
70 fileapi::FileSystemContext* file_system_context_; | 81 fileapi::FileSystemContext* file_system_context_; |
71 | 82 |
72 // Render process id, used to check whether the process can access cookies. | 83 // Render process id, used to check whether the process can access cookies. |
73 int render_process_id_; | 84 int render_process_id_; |
74 | 85 |
75 // Render frame id, used to check tab specific cookie policy. | 86 // Render frame id, used to check tab specific cookie policy. |
76 int render_frame_id_; | 87 int render_frame_id_; |
77 | 88 |
78 // NOTE: Weak pointers must be invalidated before all other member variables. | 89 // NOTE: Weak pointers must be invalidated before all other member variables. |
79 base::WeakPtrFactory<MediaResourceGetterImpl> weak_factory_; | 90 base::WeakPtrFactory<MediaResourceGetterImpl> weak_factory_; |
80 | 91 |
81 DISALLOW_COPY_AND_ASSIGN(MediaResourceGetterImpl); | 92 DISALLOW_COPY_AND_ASSIGN(MediaResourceGetterImpl); |
82 }; | 93 }; |
83 | 94 |
84 } // namespace content | 95 } // namespace content |
85 | 96 |
86 #endif // CONTENT_BROWSER_MEDIA_ANDROID_MEDIA_RESOURCE_GETTER_IMPL_H_ | 97 #endif // CONTENT_BROWSER_MEDIA_ANDROID_MEDIA_RESOURCE_GETTER_IMPL_H_ |
OLD | NEW |