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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/android/cookies_retriever_impl.cc
diff --git a/content/browser/android/cookies_retriever_impl.cc b/content/browser/android/cookies_retriever_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..62ab9b060a586a31b5831aab01e644d36692097e
--- /dev/null
+++ b/content/browser/android/cookies_retriever_impl.cc
@@ -0,0 +1,67 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/browser/android/cookies_retriever_impl.h"
+
+#include "base/bind.h"
+#include "content/public/browser/browser_thread.h"
+#include "googleurl/src/gurl.h"
+#include "net/cookies/cookie_store.h"
+#include "net/url_request/url_request_context.h"
+#include "net/url_request/url_request_context_getter.h"
+
+using content::BrowserThread;
+
+namespace content {
+
+CookiesRetrieverImpl::CookiesRetrieverImpl(
+ net::URLRequestContextGetter* context_getter)
+ : context_getter_(context_getter) {
+}
+
+CookiesRetrieverImpl::~CookiesRetrieverImpl() {
+}
+
+void CookiesRetrieverImpl::GetCookiesAsync(std::string url,
+ const media::CookiesRetriever::GetCookieCB& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ 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
+ get_cookies_cb_ = callback;
+ BrowserThread::PostTask(
+ BrowserThread::IO,
+ FROM_HERE,
+ base::Bind(&CookiesRetrieverImpl::RequestCookies,
+ 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.
+}
+
+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
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ net::CookieOptions options;
+ options.set_include_httponly();
+ net::CookieStore* cookie_store =
+ context_getter_->GetURLRequestContext()->cookie_store();
+ if (cookie_store) {
+ cookie_store->GetCookiesWithOptionsAsync(
+ 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.
+ this));
+ } else {
+ std::string cookies;
+ ReturnCookies(cookies);
+ }
+}
+
+void CookiesRetrieverImpl::ReturnCookies(const std::string& cookies) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ BrowserThread::PostTask(
+ BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(&CookiesRetrieverImpl::GetCookiesCallback, this, cookies));
+}
+
+void CookiesRetrieverImpl::GetCookiesCallback(const std::string& cookies) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ get_cookies_cb_.Run(cookies);
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698