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

Side by Side Diff: content/browser/android/cookies_retriever_impl.cc

Issue 10919075: Move android mediaplayer from render process to browser process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressing comments 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 #include "content/browser/android/cookies_retriever_impl.h"
6
7 #include "base/bind.h"
8 #include "content/public/browser/browser_thread.h"
9 #include "googleurl/src/gurl.h"
10 #include "net/cookies/cookie_store.h"
11 #include "net/url_request/url_request_context.h"
12 #include "net/url_request/url_request_context_getter.h"
13
14 using content::BrowserThread;
15
16 namespace content {
17
18 CookiesRetrieverImpl::CookiesRetrieverImpl(
19 net::URLRequestContextGetter* context_getter)
20 : context_getter_(context_getter) {
21 }
22
23 CookiesRetrieverImpl::~CookiesRetrieverImpl() {
24 }
25
26 void CookiesRetrieverImpl::GetCookiesAsync(std::string url,
27 const media::CookiesRetriever::GetCookieCB& callback) {
28 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
29 url_ = url;
scherkus (not reviewing) 2012/09/07 13:17:35 what happens if I call this multiple times with di
qinmin 2012/09/07 22:48:27 passed url to the RequestCookies closure. On 2012
30 get_cookies_cb_ = callback;
31 BrowserThread::PostTask(
32 BrowserThread::IO,
33 FROM_HERE,
34 base::Bind(&CookiesRetrieverImpl::RequestCookies,
35 this));
scherkus (not reviewing) 2012/09/07 13:17:35 instead of storing url_ and get_cookies_cb_ in the
qinmin 2012/09/07 22:48:27 Done.
36 }
37
38 void CookiesRetrieverImpl::RequestCookies() {
scherkus (not reviewing) 2012/09/07 13:17:35 this function should be: RequestCookies(const std:
qinmin 2012/09/07 22:48:27 Done. Use partial binding to pass GetCookiesCB
39 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
40 net::CookieOptions options;
41 options.set_include_httponly();
42 net::CookieStore* cookie_store =
43 context_getter_->GetURLRequestContext()->cookie_store();
44 if (cookie_store) {
45 cookie_store->GetCookiesWithOptionsAsync(
46 GURL(url_), options, base::Bind(&CookiesRetrieverImpl::ReturnCookies,
scherkus (not reviewing) 2012/09/07 13:17:35 you're accessing url_ on different threads
qinmin 2012/09/07 22:48:27 Done. passing url to this function.
47 this));
48 } else {
49 std::string cookies;
50 ReturnCookies(cookies);
51 }
52 }
53
54 void CookiesRetrieverImpl::ReturnCookies(const std::string& cookies) {
55 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
56 BrowserThread::PostTask(
57 BrowserThread::UI,
58 FROM_HERE,
59 base::Bind(&CookiesRetrieverImpl::GetCookiesCallback, this, cookies));
60 }
61
62 void CookiesRetrieverImpl::GetCookiesCallback(const std::string& cookies) {
63 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
64 get_cookies_cb_.Run(cookies);
65 }
66
67 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698