| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/loader/resource_scheduler.h" | 5 #include "content/browser/loader/resource_scheduler.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_vector.h" | 7 #include "base/memory/scoped_vector.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "content/browser/browser_thread_impl.h" | 10 #include "content/browser/browser_thread_impl.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 }; | 86 }; |
| 87 | 87 |
| 88 class FakeResourceContext : public ResourceContext { | 88 class FakeResourceContext : public ResourceContext { |
| 89 private: | 89 private: |
| 90 virtual net::HostResolver* GetHostResolver() OVERRIDE { return NULL; } | 90 virtual net::HostResolver* GetHostResolver() OVERRIDE { return NULL; } |
| 91 virtual net::URLRequestContext* GetRequestContext() OVERRIDE { return NULL; } | 91 virtual net::URLRequestContext* GetRequestContext() OVERRIDE { return NULL; } |
| 92 virtual bool AllowMicAccess(const GURL& origin) OVERRIDE { return false; } | 92 virtual bool AllowMicAccess(const GURL& origin) OVERRIDE { return false; } |
| 93 virtual bool AllowCameraAccess(const GURL& origin) OVERRIDE { return false; } | 93 virtual bool AllowCameraAccess(const GURL& origin) OVERRIDE { return false; } |
| 94 }; | 94 }; |
| 95 | 95 |
| 96 class FakeURLRequestContextSelector | |
| 97 : public ResourceMessageFilter::URLRequestContextSelector { | |
| 98 private: | |
| 99 virtual net::URLRequestContext* GetRequestContext( | |
| 100 ResourceType::Type) OVERRIDE { | |
| 101 return NULL; | |
| 102 } | |
| 103 }; | |
| 104 | |
| 105 class FakeResourceMessageFilter : public ResourceMessageFilter { | 96 class FakeResourceMessageFilter : public ResourceMessageFilter { |
| 106 public: | 97 public: |
| 107 FakeResourceMessageFilter(int child_id) | 98 FakeResourceMessageFilter(int child_id) |
| 108 : ResourceMessageFilter(child_id, | 99 : ResourceMessageFilter( |
| 109 PROCESS_TYPE_RENDERER, | 100 child_id, |
| 110 &context_, | 101 PROCESS_TYPE_RENDERER, |
| 111 NULL /* appcache_service */, | 102 NULL /* appcache_service */, |
| 112 NULL /* blob_storage_context */, | 103 NULL /* blob_storage_context */, |
| 113 NULL /* file_system_context */, | 104 NULL /* file_system_context */, |
| 114 new FakeURLRequestContextSelector) { | 105 base::Bind(&FakeResourceMessageFilter::GetContexts, |
| 106 base::Unretained(this))) { |
| 115 } | 107 } |
| 116 | 108 |
| 117 private: | 109 private: |
| 118 virtual ~FakeResourceMessageFilter() {} | 110 virtual ~FakeResourceMessageFilter() {} |
| 119 | 111 |
| 112 void GetContexts(const ResourceHostMsg_Request& request, |
| 113 ResourceContext** resource_context, |
| 114 net::URLRequestContext** request_context) { |
| 115 *resource_context = &context_; |
| 116 *request_context = NULL; |
| 117 } |
| 118 |
| 120 FakeResourceContext context_; | 119 FakeResourceContext context_; |
| 121 }; | 120 }; |
| 122 | 121 |
| 123 class ResourceSchedulerTest : public testing::Test { | 122 class ResourceSchedulerTest : public testing::Test { |
| 124 protected: | 123 protected: |
| 125 ResourceSchedulerTest() | 124 ResourceSchedulerTest() |
| 126 : next_request_id_(0), | 125 : next_request_id_(0), |
| 127 message_loop_(base::MessageLoop::TYPE_IO), | 126 message_loop_(base::MessageLoop::TYPE_IO), |
| 128 ui_thread_(BrowserThread::UI, &message_loop_), | 127 ui_thread_(BrowserThread::UI, &message_loop_), |
| 129 io_thread_(BrowserThread::IO, &message_loop_) { | 128 io_thread_(BrowserThread::IO, &message_loop_) { |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 EXPECT_FALSE(idle->started()); | 425 EXPECT_FALSE(idle->started()); |
| 427 | 426 |
| 428 scheduler_.OnWillInsertBody(kChildId, kRouteId); | 427 scheduler_.OnWillInsertBody(kChildId, kRouteId); |
| 429 EXPECT_FALSE(request->started()); | 428 EXPECT_FALSE(request->started()); |
| 430 EXPECT_FALSE(idle->started()); | 429 EXPECT_FALSE(idle->started()); |
| 431 } | 430 } |
| 432 | 431 |
| 433 } // unnamed namespace | 432 } // unnamed namespace |
| 434 | 433 |
| 435 } // namespace content | 434 } // namespace content |
| OLD | NEW |