| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 net::URLRequest, meaning it is a "simple" | 6 // The class is implemented using net::URLRequest, meaning it is a "simple" |
| 7 // version that directly issues requests. The more complicated one used in the | 7 // version that directly issues requests. The more complicated one used in the |
| 8 // browser uses IPC. | 8 // browser uses IPC. |
| 9 // | 9 // |
| 10 // Because net::URLRequest only provides an asynchronous resource loading API, | 10 // Because net::URLRequest only provides an asynchronous resource loading API, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 // perform URL loads. See renderer/resource_dispatcher.h for details on an | 30 // perform URL loads. See renderer/resource_dispatcher.h for details on an |
| 31 // alternate implementation that defers fetching to another process. | 31 // alternate implementation that defers fetching to another process. |
| 32 | 32 |
| 33 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" | 33 #include "webkit/tools/test_shell/simple_resource_loader_bridge.h" |
| 34 | 34 |
| 35 #include "base/file_path.h" | 35 #include "base/file_path.h" |
| 36 #include "base/file_util.h" | 36 #include "base/file_util.h" |
| 37 #include "base/logging.h" | 37 #include "base/logging.h" |
| 38 #include "base/message_loop.h" | 38 #include "base/message_loop.h" |
| 39 #include "base/message_loop_proxy.h" | 39 #include "base/message_loop_proxy.h" |
| 40 #if defined(OS_MACOSX) || defined(OS_WIN) | |
| 41 #include "base/nss_util.h" | |
| 42 #endif | |
| 43 #include "base/memory/ref_counted.h" | 40 #include "base/memory/ref_counted.h" |
| 44 #include "base/time.h" | 41 #include "base/time.h" |
| 45 #include "base/timer.h" | 42 #include "base/timer.h" |
| 46 #include "base/threading/thread.h" | 43 #include "base/threading/thread.h" |
| 47 #include "base/synchronization/waitable_event.h" | 44 #include "base/synchronization/waitable_event.h" |
| 48 #include "net/base/cookie_store.h" | 45 #include "net/base/cookie_store.h" |
| 49 #include "net/base/file_stream.h" | 46 #include "net/base/file_stream.h" |
| 50 #include "net/base/io_buffer.h" | 47 #include "net/base/io_buffer.h" |
| 51 #include "net/base/load_flags.h" | 48 #include "net/base/load_flags.h" |
| 52 #include "net/base/net_errors.h" | 49 #include "net/base/net_errors.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 66 #include "webkit/fileapi/file_system_context.h" | 63 #include "webkit/fileapi/file_system_context.h" |
| 67 #include "webkit/fileapi/file_system_dir_url_request_job.h" | 64 #include "webkit/fileapi/file_system_dir_url_request_job.h" |
| 68 #include "webkit/fileapi/file_system_url_request_job.h" | 65 #include "webkit/fileapi/file_system_url_request_job.h" |
| 69 #include "webkit/glue/resource_loader_bridge.h" | 66 #include "webkit/glue/resource_loader_bridge.h" |
| 70 #include "webkit/tools/test_shell/simple_appcache_system.h" | 67 #include "webkit/tools/test_shell/simple_appcache_system.h" |
| 71 #include "webkit/tools/test_shell/simple_file_writer.h" | 68 #include "webkit/tools/test_shell/simple_file_writer.h" |
| 72 #include "webkit/tools/test_shell/simple_socket_stream_bridge.h" | 69 #include "webkit/tools/test_shell/simple_socket_stream_bridge.h" |
| 73 #include "webkit/tools/test_shell/test_shell_request_context.h" | 70 #include "webkit/tools/test_shell/test_shell_request_context.h" |
| 74 #include "webkit/tools/test_shell/test_shell_webblobregistry_impl.h" | 71 #include "webkit/tools/test_shell/test_shell_webblobregistry_impl.h" |
| 75 | 72 |
| 73 #if defined(OS_MACOSX) || defined(OS_WIN) |
| 74 #include "crypto/nss_util.h" |
| 75 #endif |
| 76 |
| 76 using webkit_glue::ResourceLoaderBridge; | 77 using webkit_glue::ResourceLoaderBridge; |
| 77 using webkit_glue::ResourceResponseInfo; | 78 using webkit_glue::ResourceResponseInfo; |
| 78 using net::StaticCookiePolicy; | 79 using net::StaticCookiePolicy; |
| 79 using net::HttpResponseHeaders; | 80 using net::HttpResponseHeaders; |
| 80 using webkit_blob::DeletableFileReference; | 81 using webkit_blob::DeletableFileReference; |
| 81 | 82 |
| 82 namespace { | 83 namespace { |
| 83 | 84 |
| 84 struct TestShellRequestContextParams { | 85 struct TestShellRequestContextParams { |
| 85 TestShellRequestContextParams( | 86 TestShellRequestContextParams( |
| (...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 905 return getter->GetResult(); | 906 return getter->GetResult(); |
| 906 } | 907 } |
| 907 | 908 |
| 908 // static | 909 // static |
| 909 bool SimpleResourceLoaderBridge::EnsureIOThread() { | 910 bool SimpleResourceLoaderBridge::EnsureIOThread() { |
| 910 if (g_io_thread) | 911 if (g_io_thread) |
| 911 return true; | 912 return true; |
| 912 | 913 |
| 913 #if defined(OS_MACOSX) || defined(OS_WIN) | 914 #if defined(OS_MACOSX) || defined(OS_WIN) |
| 914 // We want to be sure to init NSPR on the main thread. | 915 // We want to be sure to init NSPR on the main thread. |
| 915 base::EnsureNSPRInit(); | 916 crypto::EnsureNSPRInit(); |
| 916 #endif | 917 #endif |
| 917 | 918 |
| 918 // Create the cache thread. We want the cache thread to outlive the IO thread, | 919 // Create the cache thread. We want the cache thread to outlive the IO thread, |
| 919 // so its lifetime is bonded to the IO thread lifetime. | 920 // so its lifetime is bonded to the IO thread lifetime. |
| 920 DCHECK(!g_cache_thread); | 921 DCHECK(!g_cache_thread); |
| 921 g_cache_thread = new base::Thread("cache"); | 922 g_cache_thread = new base::Thread("cache"); |
| 922 CHECK(g_cache_thread->StartWithOptions( | 923 CHECK(g_cache_thread->StartWithOptions( |
| 923 base::Thread::Options(MessageLoop::TYPE_IO, 0))); | 924 base::Thread::Options(MessageLoop::TYPE_IO, 0))); |
| 924 | 925 |
| 925 g_io_thread = new IOThread(); | 926 g_io_thread = new IOThread(); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 947 | 948 |
| 948 // static | 949 // static |
| 949 scoped_refptr<base::MessageLoopProxy> | 950 scoped_refptr<base::MessageLoopProxy> |
| 950 SimpleResourceLoaderBridge::GetIoThread() { | 951 SimpleResourceLoaderBridge::GetIoThread() { |
| 951 if (!EnsureIOThread()) { | 952 if (!EnsureIOThread()) { |
| 952 LOG(DFATAL) << "Failed to create IO thread."; | 953 LOG(DFATAL) << "Failed to create IO thread."; |
| 953 return NULL; | 954 return NULL; |
| 954 } | 955 } |
| 955 return g_io_thread->message_loop_proxy(); | 956 return g_io_thread->message_loop_proxy(); |
| 956 } | 957 } |
| OLD | NEW |