OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "mojo/services/network/cookie_store_impl.h" | 5 #include "mojo/services/network/cookie_store_impl.h" |
6 | 6 |
7 #include "mojo/common/url_type_converters.h" | 7 #include "mojo/common/url_type_converters.h" |
8 #include "mojo/services/network/network_context.h" | 8 #include "mojo/services/network/network_context.h" |
9 #include "net/cookies/cookie_store.h" | 9 #include "net/cookies/cookie_store.h" |
10 #include "net/url_request/url_request_context.h" | 10 #include "net/url_request/url_request_context.h" |
11 | 11 |
12 namespace mojo { | 12 namespace mojo { |
13 namespace { | 13 namespace { |
14 | 14 |
15 void AdaptGetCookiesCallback(const Callback<void(String)>& callback, | 15 void AdaptGetCookiesCallback(const Callback<void(String)>& callback, |
16 const std::string& cookies) { | 16 const std::string& cookies) { |
17 callback.Run(cookies); | 17 callback.Run(cookies); |
18 } | 18 } |
19 | 19 |
20 void AdaptSetCookieCallback(const Callback<void(bool)>& callback, | 20 void AdaptSetCookieCallback(const Callback<void(bool)>& callback, |
21 bool success) { | 21 bool success) { |
22 callback.Run(success); | 22 callback.Run(success); |
23 } | 23 } |
24 | 24 |
25 } // namespace | 25 } // namespace |
26 | 26 |
27 CookieStoreImpl::CookieStoreImpl(NetworkContext* context, | 27 CookieStoreImpl::CookieStoreImpl( |
28 const GURL& origin) | 28 NetworkContext* context, |
| 29 const GURL& origin, |
| 30 scoped_ptr<mojo::AppRefCount> app_refcount) |
29 : context_(context), | 31 : context_(context), |
30 origin_(origin) { | 32 origin_(origin), |
| 33 app_refcount_(app_refcount.Pass()) { |
31 } | 34 } |
32 | 35 |
33 CookieStoreImpl::~CookieStoreImpl() { | 36 CookieStoreImpl::~CookieStoreImpl() { |
34 } | 37 } |
35 | 38 |
36 void CookieStoreImpl::Get(const String& url, | 39 void CookieStoreImpl::Get(const String& url, |
37 const Callback<void(String)>& callback) { | 40 const Callback<void(String)>& callback) { |
38 // TODO(darin): Perform origin restriction. | 41 // TODO(darin): Perform origin restriction. |
39 net::CookieStore* store = context_->url_request_context()->cookie_store(); | 42 net::CookieStore* store = context_->url_request_context()->cookie_store(); |
40 if (!store) { | 43 if (!store) { |
(...skipping 16 matching lines...) Expand all Loading... |
57 return; | 60 return; |
58 } | 61 } |
59 store->SetCookieWithOptionsAsync( | 62 store->SetCookieWithOptionsAsync( |
60 url.To<GURL>(), | 63 url.To<GURL>(), |
61 cookie, | 64 cookie, |
62 net::CookieOptions(), | 65 net::CookieOptions(), |
63 base::Bind(&AdaptSetCookieCallback, callback)); | 66 base::Bind(&AdaptSetCookieCallback, callback)); |
64 } | 67 } |
65 | 68 |
66 } // namespace mojo | 69 } // namespace mojo |
OLD | NEW |