OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "chrome_frame/test/net/test_automation_provider.h" | 5 #include "chrome_frame/test/net/test_automation_provider.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "chrome/test/automation/automation_messages.h" | 8 #include "chrome/test/automation/automation_messages.h" |
9 | 9 |
10 #include "chrome_frame/test/net/test_automation_resource_message_filter.h" | 10 #include "chrome_frame/test/net/test_automation_resource_message_filter.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 if (CFTestsDisabled()) | 67 if (CFTestsDisabled()) |
68 return NULL; | 68 return NULL; |
69 | 69 |
70 if (request->url().SchemeIs("http") || request->url().SchemeIs("https")) { | 70 if (request->url().SchemeIs("http") || request->url().SchemeIs("https")) { |
71 // Only look at requests that don't have any user data. | 71 // Only look at requests that don't have any user data. |
72 // ResourceDispatcherHost uses the user data for requests that it manages. | 72 // ResourceDispatcherHost uses the user data for requests that it manages. |
73 // We don't want to mess with those. | 73 // We don't want to mess with those. |
74 | 74 |
75 // We could also check if the current thread is our TestUrlRequest thread | 75 // We could also check if the current thread is our TestUrlRequest thread |
76 // and only intercept requests that belong to that thread. | 76 // and only intercept requests that belong to that thread. |
77 if (g_provider_instance_ && request->GetUserData(NULL) == NULL) { | 77 if (g_provider_instance_ && request->GetUserData(NULL) == NULL && |
78 DCHECK(g_provider_instance_->tab_handle_ != -1); | 78 g_provider_instance_->tab_handle_ != -1) { |
79 // We generate our own request id which is also what | 79 // We generate our own request id which is also what |
80 // ResourceDispatcherHost does (well, the id is actually generated by | 80 // ResourceDispatcherHost does (well, the id is actually generated by |
81 // ResourceDispatcher). Since these requests are divided into with | 81 // ResourceDispatcher). Since these requests are divided into with |
82 // and without userdata, we're OK. However, just to make debugging | 82 // and without userdata, we're OK. However, just to make debugging |
83 // a little easier, we have a significantly higher start value. | 83 // a little easier, we have a significantly higher start value. |
84 static int new_id = 0x00100000; | 84 static int new_id = 0x00100000; |
85 URLRequestAutomationJob* job = new URLRequestAutomationJob(request, | 85 URLRequestAutomationJob* job = new URLRequestAutomationJob(request, |
86 g_provider_instance_->tab_handle_, new_id++, | 86 g_provider_instance_->tab_handle_, new_id++, |
87 g_provider_instance_->filter_, false); | 87 g_provider_instance_->filter_, false); |
88 return job; | 88 return job; |
89 } | 89 } |
90 } | 90 } |
91 | 91 |
92 return NULL; | 92 return NULL; |
93 } | 93 } |
94 | 94 |
95 // static | 95 // static |
96 TestAutomationProvider* TestAutomationProvider::NewAutomationProvider( | 96 TestAutomationProvider* TestAutomationProvider::NewAutomationProvider( |
97 Profile* p, const std::string& channel, | 97 Profile* p, const std::string& channel, |
98 TestAutomationProviderDelegate* delegate) { | 98 TestAutomationProviderDelegate* delegate) { |
99 TestAutomationProvider* automation = new TestAutomationProvider(p, delegate); | 99 TestAutomationProvider* automation = new TestAutomationProvider(p, delegate); |
100 automation->ConnectToChannel(channel); | 100 automation->ConnectToChannel(channel); |
101 automation->SetExpectedTabCount(1); | 101 automation->SetExpectedTabCount(1); |
102 return automation; | 102 return automation; |
103 } | 103 } |
OLD | NEW |