| 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 "components/html_viewer/web_cookie_jar_impl.h" | 5 #include "components/html_viewer/web_cookie_jar_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "third_party/WebKit/public/platform/WebURL.h" | 8 #include "third_party/WebKit/public/platform/WebURL.h" |
| 9 | 9 |
| 10 using mojo::String; | 10 using mojo::String; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 store_->Set(url.string().utf8(), cookie.utf8(), | 36 store_->Set(url.string().utf8(), cookie.utf8(), |
| 37 base::Bind(&CopyBool, &success)); | 37 base::Bind(&CopyBool, &success)); |
| 38 | 38 |
| 39 // Wait to ensure the cookie was set before advancing. That way any | 39 // Wait to ensure the cookie was set before advancing. That way any |
| 40 // subsequent URL request will see the changes to the cookie store. | 40 // subsequent URL request will see the changes to the cookie store. |
| 41 // | 41 // |
| 42 // TODO(darin): Consider using associated message pipes for the CookieStore | 42 // TODO(darin): Consider using associated message pipes for the CookieStore |
| 43 // and URLLoader, so that we could let this method call run asynchronously | 43 // and URLLoader, so that we could let this method call run asynchronously |
| 44 // without suffering an ordering problem. See crbug/386825. | 44 // without suffering an ordering problem. See crbug/386825. |
| 45 // | 45 // |
| 46 store_.WaitForIncomingResponse(); | 46 store_.WaitForIncomingMethodCall(); |
| 47 } | 47 } |
| 48 | 48 |
| 49 blink::WebString WebCookieJarImpl::cookies( | 49 blink::WebString WebCookieJarImpl::cookies( |
| 50 const blink::WebURL& url, | 50 const blink::WebURL& url, |
| 51 const blink::WebURL& first_party_for_cookies) { | 51 const blink::WebURL& first_party_for_cookies) { |
| 52 String result; | 52 String result; |
| 53 store_->Get(url.string().utf8(), base::Bind(&CopyString, &result)); | 53 store_->Get(url.string().utf8(), base::Bind(&CopyString, &result)); |
| 54 | 54 |
| 55 // Wait for the result. Since every outbound request we make to the cookie | 55 // Wait for the result. Since every outbound request we make to the cookie |
| 56 // store is followed up with WaitForIncomingResponse, we can be sure that | 56 // store is followed up with WaitForIncomingMethodCall, we can be sure that |
| 57 // the next incoming method call will be the response to our request. | 57 // the next incoming method call will be the response to our request. |
| 58 store_.WaitForIncomingResponse(); | 58 store_.WaitForIncomingMethodCall(); |
| 59 if (!result) | 59 if (!result) |
| 60 return blink::WebString(); | 60 return blink::WebString(); |
| 61 | 61 |
| 62 return blink::WebString::fromUTF8(result); | 62 return blink::WebString::fromUTF8(result); |
| 63 } | 63 } |
| 64 | 64 |
| 65 blink::WebString WebCookieJarImpl::cookieRequestHeaderFieldValue( | 65 blink::WebString WebCookieJarImpl::cookieRequestHeaderFieldValue( |
| 66 const blink::WebURL& url, | 66 const blink::WebURL& url, |
| 67 const blink::WebURL& first_party_for_cookies) { | 67 const blink::WebURL& first_party_for_cookies) { |
| 68 return cookies(url, first_party_for_cookies); | 68 return cookies(url, first_party_for_cookies); |
| 69 } | 69 } |
| 70 | 70 |
| 71 } // namespace html_viewer | 71 } // namespace html_viewer |
| OLD | NEW |