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

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: add the missing cookies_retriever.h file 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;
30 get_cookies_cb_ = callback;
31 BrowserThread::PostTask(
32 BrowserThread::IO,
33 FROM_HERE,
34 base::Bind(&CookiesRetrieverImpl::RequestCookies,
35 this));
36 }
37
38 void CookiesRetrieverImpl::RequestCookies() {
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,
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 cookies_ = cookies;
Yaron 2012/09/05 07:03:56 Hrmm. Could you you have multiple calls to ReturnC
qinmin 2012/09/05 19:34:42 That should not happen in the current code logic.
57 BrowserThread::PostTask(
58 BrowserThread::UI,
59 FROM_HERE,
60 base::Bind(&CookiesRetrieverImpl::GetCookiesCallback, this));
61 }
62
63 void CookiesRetrieverImpl::GetCookiesCallback() {
64 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
65 get_cookies_cb_.Run(cookies_);
66 }
67
68 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698