OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 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. |
| 4 |
| 5 #ifndef CONTENT_BROWSER_ANDROID_MEDIA_RESOURCE_GETTER_IMPL_H_ |
| 6 #define CONTENT_BROWSER_ANDROID_MEDIA_RESOURCE_GETTER_IMPL_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/memory/ref_counted.h" |
| 11 #include "base/memory/weak_ptr.h" |
| 12 #include "base/synchronization/waitable_event.h" |
| 13 #include "content/browser/fileapi/fileapi_message_filter.h" |
| 14 #include "media/base/android/media_resource_getter.h" |
| 15 #include "net/cookies/canonical_cookie.h" |
| 16 |
| 17 namespace net { |
| 18 class URLRequestContextGetter; |
| 19 } |
| 20 |
| 21 namespace content { |
| 22 |
| 23 class BrowserContext; |
| 24 class ResourceContext; |
| 25 |
| 26 // This class implements media::MediaResourceGetter to retrieve resources |
| 27 // asynchronously on the UI thread. |
| 28 class MediaResourceGetterImpl : public media::MediaResourceGetter { |
| 29 public: |
| 30 // Construct a MediaResourceGetterImpl object. |browser_context| and |
| 31 // |renderer_id| are passed to retrieve the CookieStore. |
| 32 // |file_system_context| are used to get the platform path. |
| 33 MediaResourceGetterImpl(BrowserContext* browser_context, |
| 34 fileapi::FileSystemContext* file_system_context, |
| 35 int renderer_id, int routing_id); |
| 36 virtual ~MediaResourceGetterImpl(); |
| 37 |
| 38 // media::MediaResourceGetter implementation. |
| 39 // Must be called on the UI thread. |
| 40 virtual void GetCookies(const std::string& url, |
| 41 const std::string& first_party_for_cookies, |
| 42 const GetCookieCB& callback) OVERRIDE; |
| 43 virtual void GetPlatformPathFromFileSystemURL( |
| 44 const std::string& url, |
| 45 const GetPlatformPathCB& callback) OVERRIDE; |
| 46 |
| 47 private: |
| 48 // Called when GetCookies() finishes. |
| 49 void GetCookiesCallback( |
| 50 const GetCookieCB& callback, const std::string& cookies); |
| 51 |
| 52 // Called when GetPlatformPathFromFileSystemURL() finishes. |
| 53 void GetPlatformPathCallback( |
| 54 const GetPlatformPathCB& callback, const std::string& platform_path); |
| 55 |
| 56 // BrowserContext to retrieve URLRequestContext and ResourceContext. |
| 57 BrowserContext* browser_context_; |
| 58 |
| 59 // FileSystemContext to be used on FILE thread. |
| 60 fileapi::FileSystemContext* file_system_context_; |
| 61 |
| 62 // Used to post tasks. |
| 63 base::WeakPtrFactory<MediaResourceGetterImpl> weak_this_; |
| 64 |
| 65 // Render process id, used to check whether the process can access cookies. |
| 66 int renderer_id_; |
| 67 |
| 68 // Routing id for the render view, used to check tab specific cookie policy. |
| 69 int routing_id_; |
| 70 |
| 71 DISALLOW_COPY_AND_ASSIGN(MediaResourceGetterImpl); |
| 72 }; |
| 73 |
| 74 } // namespace content |
| 75 |
| 76 #endif // CONTENT_BROWSER_ANDROID_MEDIA_RESOURCE_GETTER_IMPL_H_ |
OLD | NEW |