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/public/renderer/resource_fetcher.h" | 5 #include "content/public/renderer/resource_fetcher.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 | 108 |
109 class EvilFetcherDelegate : public FetcherDelegate { | 109 class EvilFetcherDelegate : public FetcherDelegate { |
110 public: | 110 public: |
111 virtual ~EvilFetcherDelegate() {} | 111 virtual ~EvilFetcherDelegate() {} |
112 | 112 |
113 void SetFetcher(ResourceFetcher* fetcher) { | 113 void SetFetcher(ResourceFetcher* fetcher) { |
114 fetcher_.reset(fetcher); | 114 fetcher_.reset(fetcher); |
115 } | 115 } |
116 | 116 |
117 virtual void OnURLFetchComplete(const WebURLResponse& response, | 117 virtual void OnURLFetchComplete(const WebURLResponse& response, |
118 const std::string& data) OVERRIDE { | 118 const std::string& data) override { |
119 FetcherDelegate::OnURLFetchComplete(response, data); | 119 FetcherDelegate::OnURLFetchComplete(response, data); |
120 | 120 |
121 // Destroy the ResourceFetcher here. We are testing that upon returning | 121 // Destroy the ResourceFetcher here. We are testing that upon returning |
122 // to the ResourceFetcher that it does not crash. This must be done after | 122 // to the ResourceFetcher that it does not crash. This must be done after |
123 // calling FetcherDelegate::OnURLFetchComplete, since deleting the fetcher | 123 // calling FetcherDelegate::OnURLFetchComplete, since deleting the fetcher |
124 // invalidates |response| and |data|. | 124 // invalidates |response| and |data|. |
125 fetcher_.reset(); | 125 fetcher_.reset(); |
126 } | 126 } |
127 | 127 |
128 private: | 128 private: |
129 scoped_ptr<ResourceFetcher> fetcher_; | 129 scoped_ptr<ResourceFetcher> fetcher_; |
130 }; | 130 }; |
131 | 131 |
132 class ResourceFetcherTests : public ContentBrowserTest { | 132 class ResourceFetcherTests : public ContentBrowserTest { |
133 public: | 133 public: |
134 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 134 virtual void SetUpCommandLine(CommandLine* command_line) override { |
135 command_line->AppendSwitch(switches::kSingleProcess); | 135 command_line->AppendSwitch(switches::kSingleProcess); |
136 #if defined(OS_WIN) | 136 #if defined(OS_WIN) |
137 // Don't want to try to create a GPU process. | 137 // Don't want to try to create a GPU process. |
138 command_line->AppendSwitch(switches::kDisableGpu); | 138 command_line->AppendSwitch(switches::kDisableGpu); |
139 #endif | 139 #endif |
140 } | 140 } |
141 | 141 |
142 RenderView* GetRenderView() { | 142 RenderView* GetRenderView() { |
143 // We could have the test on the UI thread get the WebContent's routing ID, | 143 // We could have the test on the UI thread get the WebContent's routing ID, |
144 // but we know this will be the first RV so skip that and just hardcode it. | 144 // but we know this will be the first RV so skip that and just hardcode it. |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 ASSERT_TRUE(test_server()->Start()); | 398 ASSERT_TRUE(test_server()->Start()); |
399 GURL url(test_server()->GetURL("echoheader?header")); | 399 GURL url(test_server()->GetURL("echoheader?header")); |
400 | 400 |
401 PostTaskToInProcessRendererAndWait( | 401 PostTaskToInProcessRendererAndWait( |
402 base::Bind( | 402 base::Bind( |
403 &ResourceFetcherTests::ResourceFetcherSetHeader, | 403 &ResourceFetcherTests::ResourceFetcherSetHeader, |
404 base::Unretained(this), url)); | 404 base::Unretained(this), url)); |
405 } | 405 } |
406 | 406 |
407 } // namespace content | 407 } // namespace content |
OLD | NEW |