Add abhijeet.k@samsung.com to AUTHORS list.
[chromium-blink-merge.git] / components / signin / core / browser / signin_manager_cookie_helper.h
blobc401c6f709dbd73b1b8c486a6108e0288de4e34e
1 // Copyright 2014 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.
5 #ifndef COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_MANAGER_COOKIE_HELPER_H_
6 #define COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_MANAGER_COOKIE_HELPER_H_
8 #include "base/callback_helpers.h"
9 #include "base/memory/ref_counted.h"
10 #include "net/cookies/canonical_cookie.h"
11 #include "net/url_request/url_request_context_getter.h"
13 namespace base {
14 class MessageLoopProxy;
17 namespace net {
18 class URLRequestContextGetter;
21 // This class fetches GAIA cookie on IO thread on behalf of SigninManager which
22 // only lives on the UI thread.
23 class SigninManagerCookieHelper
24 : public base::RefCountedThreadSafe<SigninManagerCookieHelper> {
25 public:
26 explicit SigninManagerCookieHelper(
27 net::URLRequestContextGetter* request_context_getter,
28 scoped_refptr<base::MessageLoopProxy> ui_thread,
29 scoped_refptr<base::MessageLoopProxy> io_thread);
31 // Starts fetching gaia cookies, which will notify its completion via
32 // callback.
33 void StartFetchingGaiaCookiesOnUIThread(
34 const base::Callback<void(const net::CookieList& cookies)>& callback);
36 // Starts fetching cookies for the given URL. This must be called on
37 // |ui_thread_|.
38 void StartFetchingCookiesOnUIThread(
39 const GURL& url,
40 const base::Callback<void(const net::CookieList& cookies)>& callback);
42 private:
43 friend class base::RefCountedThreadSafe<SigninManagerCookieHelper>;
44 ~SigninManagerCookieHelper();
46 // Fetch cookies for the given URL. This must be called on |io_thread_|.
47 void FetchCookiesOnIOThread(const GURL& url);
49 // Callback for fetching cookies. This must be called on |io_thread_|.
50 void OnCookiesFetched(const net::CookieList& cookies);
52 // Notifies the completion callback. This must be called on |ui_thread_|.
53 void NotifyOnUIThread(const net::CookieList& cookies);
55 scoped_refptr<net::URLRequestContextGetter> request_context_getter_;
56 // This only mutates on |ui_thread_|.
57 base::Callback<void(const net::CookieList& cookies)> completion_callback_;
59 // The MessageLoopProxy that this class uses as its UI thread.
60 scoped_refptr<base::MessageLoopProxy> ui_thread_;
61 // The MessageLoopProxy that this class uses as its IO thread.
62 scoped_refptr<base::MessageLoopProxy> io_thread_;
63 DISALLOW_COPY_AND_ASSIGN(SigninManagerCookieHelper);
66 #endif // COMPONENTS_SIGNIN_CORE_BROWSER_SIGNIN_MANAGER_COOKIE_HELPER_H_