Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1256)

Side by Side Diff: content/browser/android/cookie_getter_impl.h

Issue 10919075: Move android mediaplayer from render process to browser process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: adding cookie policy check and fix the threading issue for CookieGetterImpl Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2012 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_COOKIE_GETTER_IMPL_H_
6 #define CONTENT_BROWSER_ANDROID_COOKIE_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 "media/base/android/cookie_getter.h"
14 #include "net/cookies/canonical_cookie.h"
15
16 namespace net {
17 class URLRequestContextGetter;
18 }
19
20 namespace content {
21
22 class BrowserContext;
23 class CookieGetterImpl;
24 class ResourceContext;
25
26 // The task object that retrieves cookie on the IO thread.
27 // TODO(qinmin): refactor this class to make the code reusable by others as
28 // there are lots of duplicated functionalities elsewhere.
29 class CookieGetterTask :
scherkus (not reviewing) 2012/09/13 10:40:14 nit: you can fwd declare this + move to .cc as Coo
qinmin 2012/09/13 18:51:16 Done.
30 public base::RefCountedThreadSafe<CookieGetterTask> {
scherkus (not reviewing) 2012/09/13 10:40:14 : goes on this line
qinmin 2012/09/13 18:51:16 Done.
31 public:
32 CookieGetterTask(BrowserContext* browser_context,
33 int renderer_id, int routing_id);
34 virtual ~CookieGetterTask();
35
36 void RequestCookies(
37 const GURL& url, const GURL& first_party_for_cookies);
38
39 std::string cookies() { return cookies_; }
40
41 private:
42 void CheckPolicyForCookies(
43 const GURL& url, const GURL& first_party_for_cookies,
44 const net::CookieList& cookie_list);
45 void ReturnCookies(const std::string& cookies);
46
47 // Context getter used to get the CookieStore.
48 net::URLRequestContextGetter* context_getter_;
49
50 // Resource context for checking cookie policies.
51 ResourceContext* resource_context_;
52
53 // Render process id, used to check whether the process can access cookies.
54 int renderer_id_;
55
56 // Routing id for the render view, used to check tab specific cookie policy.
57 int routing_id_;
58
59 // Return value.
60 std::string cookies_;
61
62 // The CookieGetterImpl object for callback.
63 base::WeakPtr<CookieGetterImpl> cookie_getter_;
64
65 // Event when all the async tasks are finished.
66 base::WaitableEvent finish_event_;
67
68 DISALLOW_COPY_AND_ASSIGN(CookieGetterTask);
69 };
70
71 // This class implements media::CookieGetter to retrive cookies
72 // asynchronously on the UI thread.
73 class CookieGetterImpl : public media::CookieGetter {
74 public:
75 // Construct a CookieGetterImpl by passing the BrowserContext reference
76 // and renderer_id to retrieve the CookieStore later.
77 CookieGetterImpl(
78 BrowserContext* browser_context, int renderer_id, int routing_id);
79 virtual ~CookieGetterImpl();
80
81 // media::CookieGetter implementation.
82 // Must be called on the UI thread.
83 virtual void GetCookies(const std::string& url,
84 const std::string& first_party_for_cookies,
85 const GetCookieCB& callback) OVERRIDE;
86
87 private:
88 void GetCookiesCallback(
89 scoped_refptr<CookieGetterTask> task, const GetCookieCB& callback);
90
91 // BrowserContext to retrieve URLRequestContext and ResourceContext.
92 BrowserContext* browser_context_;
93
94 // Used to post tasks.
95 base::WeakPtrFactory<CookieGetterImpl> weak_this_;
96
97 // Render process id, used to check whether the process can access cookies.
98 int renderer_id_;
99
100 // Routing id for the render view, used to check tab specific cookie policy.
101 int routing_id_;
102
103 DISALLOW_COPY_AND_ASSIGN(CookieGetterImpl);
104 };
105
106 } // namespace content
107
108 #endif // CONTENT_BROWSER_ANDROID_COOKIE_GETTER_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698