Supervised user import: Listen for profile creation/deletion
[chromium-blink-merge.git] / content / browser / media / android / media_resource_getter_impl.h
blob9a55fcb7c2c5f7b3389b8d75965d29d70a45cf83
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_BROWSER_MEDIA_ANDROID_MEDIA_RESOURCE_GETTER_IMPL_H_
6 #define CONTENT_BROWSER_MEDIA_ANDROID_MEDIA_RESOURCE_GETTER_IMPL_H_
8 #include <jni.h>
9 #include <string>
11 #include "base/memory/ref_counted.h"
12 #include "base/memory/weak_ptr.h"
13 #include "base/synchronization/waitable_event.h"
14 #include "media/base/android/media_resource_getter.h"
15 #include "media/base/android/media_url_interceptor.h"
16 #include "net/base/auth.h"
17 #include "net/cookies/canonical_cookie.h"
19 namespace storage {
20 class FileSystemContext;
23 namespace net {
24 class URLRequestContextGetter;
27 namespace content {
29 class BrowserContext;
30 class ResourceContext;
32 // This class implements media::MediaResourceGetter to retrieve resources
33 // asynchronously on the UI thread.
34 class MediaResourceGetterImpl : public media::MediaResourceGetter {
35 public:
36 // Construct a MediaResourceGetterImpl object. |browser_context| and
37 // |render_process_id| are passed to retrieve the CookieStore.
38 // |file_system_context| are used to get the platform path.
39 MediaResourceGetterImpl(BrowserContext* browser_context,
40 storage::FileSystemContext* file_system_context,
41 int render_process_id,
42 int render_frame_id);
43 ~MediaResourceGetterImpl() override;
45 // media::MediaResourceGetter implementation.
46 // Must be called on the UI thread.
47 void GetAuthCredentials(const GURL& url,
48 const GetAuthCredentialsCB& callback) override;
49 void GetCookies(const GURL& url,
50 const GURL& first_party_for_cookies,
51 const GetCookieCB& callback) override;
52 void GetPlatformPathFromURL(const GURL& url,
53 const GetPlatformPathCB& callback) override;
54 void ExtractMediaMetadata(const std::string& url,
55 const std::string& cookies,
56 const std::string& user_agent,
57 const ExtractMediaMetadataCB& callback) override;
58 void ExtractMediaMetadata(const int fd,
59 const int64 offset,
60 const int64 size,
61 const ExtractMediaMetadataCB& callback) override;
63 static bool RegisterMediaResourceGetter(JNIEnv* env);
65 private:
66 // Called when GetAuthCredentials() finishes.
67 void GetAuthCredentialsCallback(
68 const GetAuthCredentialsCB& callback,
69 const net::AuthCredentials& credentials);
71 // Called when GetCookies() finishes.
72 void GetCookiesCallback(
73 const GetCookieCB& callback, const std::string& cookies);
75 // Called when GetPlatformPathFromFileSystemURL() finishes.
76 void GetPlatformPathCallback(
77 const GetPlatformPathCB& callback, const std::string& platform_path);
79 // BrowserContext to retrieve URLRequestContext and ResourceContext.
80 BrowserContext* browser_context_;
82 // FileSystemContext to be used on FILE thread.
83 storage::FileSystemContext* file_system_context_;
85 // Render process id, used to check whether the process can access cookies.
86 int render_process_id_;
88 // Render frame id, used to check tab specific cookie policy.
89 int render_frame_id_;
91 // NOTE: Weak pointers must be invalidated before all other member variables.
92 base::WeakPtrFactory<MediaResourceGetterImpl> weak_factory_;
94 DISALLOW_COPY_AND_ASSIGN(MediaResourceGetterImpl);
97 } // namespace content
99 #endif // CONTENT_BROWSER_MEDIA_ANDROID_MEDIA_RESOURCE_GETTER_IMPL_H_