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

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: 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 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..c58efe452727bf1e472bfac56179e4eb80591188
--- /dev/null
+++ b/content/browser/android/cookies_retriever_impl.cc
@@ -0,0 +1,68 @@
+// 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;
+ get_cookies_cb_ = callback;
+ BrowserThread::PostTask(
+ BrowserThread::IO,
+ FROM_HERE,
+ base::Bind(&CookiesRetrieverImpl::RequestCookies,
+ this));
+}
+
+void CookiesRetrieverImpl::RequestCookies() {
+ 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,
+ this));
+ } else {
+ std::string cookies;
+ ReturnCookies(cookies);
+ }
+}
+
+void CookiesRetrieverImpl::ReturnCookies(const std::string& cookies) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ 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.
+ BrowserThread::PostTask(
+ BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(&CookiesRetrieverImpl::GetCookiesCallback, this));
+}
+
+void CookiesRetrieverImpl::GetCookiesCallback() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ get_cookies_cb_.Run(cookies_);
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698