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

Unified Diff: content/browser/android/cookie_getter_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/cookie_getter_impl.cc
diff --git a/content/browser/android/cookie_getter_impl.cc b/content/browser/android/cookie_getter_impl.cc
new file mode 100644
index 0000000000000000000000000000000000000000..741bf6b77ac7faf8c545361ab4814e67f556437d
--- /dev/null
+++ b/content/browser/android/cookie_getter_impl.cc
@@ -0,0 +1,70 @@
+// 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/cookie_getter_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 {
+
+CookieGetterImpl::CookieGetterImpl(
+ net::URLRequestContextGetter* context_getter)
+ : context_getter_(context_getter),
+ ALLOW_THIS_IN_INITIALIZER_LIST(weak_this_(this)) {
+}
+
+CookieGetterImpl::~CookieGetterImpl() {}
+
+void CookieGetterImpl::GetCookies(
+ const std::string& url, const GetCookieCB& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ BrowserThread::PostTask(
+ BrowserThread::IO,
+ FROM_HERE,
+ base::Bind(&CookieGetterImpl::RequestCookies,
+ weak_this_.GetWeakPtr(), url, callback));
+}
+
+void CookieGetterImpl::RequestCookies(
+ const std::string& url, const GetCookieCB& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ net::CookieOptions options;
+ options.set_include_httponly();
+ net::CookieStore* cookie_store =
+ context_getter_->GetURLRequestContext()->cookie_store();
nilesh 2012/09/11 05:48:48 I think you are supposed to ask the request contex
qinmin 2012/09/12 23:12:52 This is getting a little more complicated. Added a
+ base::Callback<void(const std::string&)> cb = base::Bind(
+ &CookieGetterImpl::ReturnCookies, weak_this_.GetWeakPtr(), callback);
+ if (cookie_store) {
+ cookie_store->GetCookiesWithOptionsAsync(
+ GURL(url), options, cb);
+ } else {
+ std::string cookies;
+ ReturnCookies(callback, cookies);
+ }
+}
+
+void CookieGetterImpl::ReturnCookies(
+ const GetCookieCB& callback, const std::string& cookies) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ BrowserThread::PostTask(
+ BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(&CookieGetterImpl::GetCookiesCallback,
+ weak_this_.GetWeakPtr(), cookies, callback));
+}
+
+void CookieGetterImpl::GetCookiesCallback(
+ const std::string& cookies, const GetCookieCB& callback) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ callback.Run(cookies);
+}
+
+} // namespace content

Powered by Google App Engine
This is Rietveld 408576698