| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 // This file contains an implementation of the ResourceLoaderBridge class. | 5 // This file contains an implementation of the ResourceLoaderBridge class. |
| 6 // The class is implemented using URLRequest, meaning it is a "simple" version | 6 // The class is implemented using URLRequest, meaning it is a "simple" version |
| 7 // that directly issues requests. The more complicated one used in the | 7 // that directly issues requests. The more complicated one used in the |
| 8 // browser uses IPC. | 8 // browser uses IPC. |
| 9 // | 9 // |
| 10 // Because URLRequest only provides an asynchronous resource loading API, this | 10 // Because URLRequest only provides an asynchronous resource loading API, this |
| (...skipping 837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 848 void SimpleResourceLoaderBridge::SetCookie(const GURL& url, | 848 void SimpleResourceLoaderBridge::SetCookie(const GURL& url, |
| 849 const GURL& first_party_for_cookies, | 849 const GURL& first_party_for_cookies, |
| 850 const std::string& cookie) { | 850 const std::string& cookie) { |
| 851 // Proxy to IO thread to synchronize w/ network loading. | 851 // Proxy to IO thread to synchronize w/ network loading. |
| 852 | 852 |
| 853 if (!EnsureIOThread()) { | 853 if (!EnsureIOThread()) { |
| 854 NOTREACHED(); | 854 NOTREACHED(); |
| 855 return; | 855 return; |
| 856 } | 856 } |
| 857 | 857 |
| 858 scoped_refptr<CookieSetter> cookie_setter = new CookieSetter(); | 858 scoped_refptr<CookieSetter> cookie_setter(new CookieSetter()); |
| 859 g_io_thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod( | 859 g_io_thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod( |
| 860 cookie_setter.get(), &CookieSetter::Set, url, cookie)); | 860 cookie_setter.get(), &CookieSetter::Set, url, cookie)); |
| 861 } | 861 } |
| 862 | 862 |
| 863 // static | 863 // static |
| 864 std::string SimpleResourceLoaderBridge::GetCookies( | 864 std::string SimpleResourceLoaderBridge::GetCookies( |
| 865 const GURL& url, const GURL& first_party_for_cookies) { | 865 const GURL& url, const GURL& first_party_for_cookies) { |
| 866 // Proxy to IO thread to synchronize w/ network loading | 866 // Proxy to IO thread to synchronize w/ network loading |
| 867 | 867 |
| 868 if (!EnsureIOThread()) { | 868 if (!EnsureIOThread()) { |
| 869 NOTREACHED(); | 869 NOTREACHED(); |
| 870 return std::string(); | 870 return std::string(); |
| 871 } | 871 } |
| 872 | 872 |
| 873 scoped_refptr<CookieGetter> getter = new CookieGetter(); | 873 scoped_refptr<CookieGetter> getter(new CookieGetter()); |
| 874 | 874 |
| 875 g_io_thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod( | 875 g_io_thread->message_loop()->PostTask(FROM_HERE, NewRunnableMethod( |
| 876 getter.get(), &CookieGetter::Get, url)); | 876 getter.get(), &CookieGetter::Get, url)); |
| 877 | 877 |
| 878 return getter->GetResult(); | 878 return getter->GetResult(); |
| 879 } | 879 } |
| 880 | 880 |
| 881 // static | 881 // static |
| 882 bool SimpleResourceLoaderBridge::EnsureIOThread() { | 882 bool SimpleResourceLoaderBridge::EnsureIOThread() { |
| 883 if (g_io_thread) | 883 if (g_io_thread) |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 926 | 926 |
| 927 // static | 927 // static |
| 928 scoped_refptr<base::MessageLoopProxy> | 928 scoped_refptr<base::MessageLoopProxy> |
| 929 SimpleResourceLoaderBridge::GetIoThread() { | 929 SimpleResourceLoaderBridge::GetIoThread() { |
| 930 if (!EnsureIOThread()) { | 930 if (!EnsureIOThread()) { |
| 931 LOG(DFATAL) << "Failed to create IO thread."; | 931 LOG(DFATAL) << "Failed to create IO thread."; |
| 932 return NULL; | 932 return NULL; |
| 933 } | 933 } |
| 934 return g_io_thread->message_loop_proxy(); | 934 return g_io_thread->message_loop_proxy(); |
| 935 } | 935 } |
| OLD | NEW |