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 <string> | 5 #include <string> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/process/process.h" | 10 #include "base/process/process.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 | 26 |
27 static const char test_page_url[] = "http://www.google.com/"; | 27 static const char test_page_url[] = "http://www.google.com/"; |
28 static const char test_page_headers[] = | 28 static const char test_page_headers[] = |
29 "HTTP/1.1 200 OK\nContent-Type:text/html\n\n"; | 29 "HTTP/1.1 200 OK\nContent-Type:text/html\n\n"; |
30 static const char test_page_mime_type[] = "text/html"; | 30 static const char test_page_mime_type[] = "text/html"; |
31 static const char test_page_charset[] = ""; | 31 static const char test_page_charset[] = ""; |
32 static const char test_page_contents[] = | 32 static const char test_page_contents[] = |
33 "<html><head><title>Google</title></head><body><h1>Google</h1></body></html>"; | 33 "<html><head><title>Google</title></head><body><h1>Google</h1></body></html>"; |
34 static const uint32 test_page_contents_len = arraysize(test_page_contents) - 1; | 34 static const uint32 test_page_contents_len = arraysize(test_page_contents) - 1; |
35 | 35 |
36 static const char kShmemSegmentName[] = "DeferredResourceLoaderTest"; | |
37 | |
38 // Listens for request response data and stores it so that it can be compared | 36 // Listens for request response data and stores it so that it can be compared |
39 // to the reference data. | 37 // to the reference data. |
40 class TestRequestCallback : public ResourceLoaderBridge::Peer { | 38 class TestRequestCallback : public ResourceLoaderBridge::Peer { |
41 public: | 39 public: |
42 TestRequestCallback() : complete_(false) { | 40 TestRequestCallback() : complete_(false) { |
43 } | 41 } |
44 | 42 |
45 virtual void OnUploadProgress(uint64 position, uint64 size) OVERRIDE { | 43 virtual void OnUploadProgress(uint64 position, uint64 size) OVERRIDE { |
46 } | 44 } |
47 | 45 |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 bool was_ignored_by_handler, | 299 bool was_ignored_by_handler, |
302 bool stale_copy_in_cache, | 300 bool stale_copy_in_cache, |
303 const std::string& security_info, | 301 const std::string& security_info, |
304 const base::TimeTicks& completion_time, | 302 const base::TimeTicks& completion_time, |
305 int64 total_transfer_size) OVERRIDE { | 303 int64 total_transfer_size) OVERRIDE { |
306 } | 304 } |
307 | 305 |
308 protected: | 306 protected: |
309 virtual void SetUp() OVERRIDE { | 307 virtual void SetUp() OVERRIDE { |
310 ResourceDispatcherTest::SetUp(); | 308 ResourceDispatcherTest::SetUp(); |
311 shared_handle_.Delete(kShmemSegmentName); | 309 EXPECT_TRUE(shared_handle_.CreateAnonymous(100)); |
312 // TODO(viettrungluu): Named shared memory is deprecated (crbug.com/345734). | |
313 // (I don't think we even need it here.) | |
314 EXPECT_TRUE(shared_handle_.CreateNamedDeprecated(kShmemSegmentName, false, | |
315 100)); | |
316 } | 310 } |
317 | 311 |
318 virtual void TearDown() OVERRIDE { | 312 virtual void TearDown() OVERRIDE { |
319 shared_handle_.Close(); | 313 shared_handle_.Close(); |
320 EXPECT_TRUE(shared_handle_.Delete(kShmemSegmentName)); | |
321 ResourceDispatcherTest::TearDown(); | 314 ResourceDispatcherTest::TearDown(); |
322 } | 315 } |
323 | 316 |
324 private: | 317 private: |
325 void set_defer_loading(bool defer) { | 318 void set_defer_loading(bool defer) { |
326 defer_loading_ = defer; | 319 defer_loading_ = defer; |
327 dispatcher_->SetDefersLoading(0, defer); | 320 dispatcher_->SetDefersLoading(0, defer); |
328 } | 321 } |
329 | 322 |
330 bool defer_loading() const { | 323 bool defer_loading() const { |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
442 response_head.error_code = net::OK; | 435 response_head.error_code = net::OK; |
443 | 436 |
444 PerformTest(response_head); | 437 PerformTest(response_head); |
445 | 438 |
446 EXPECT_EQ(base::TimeTicks(), response_info().load_timing.request_start); | 439 EXPECT_EQ(base::TimeTicks(), response_info().load_timing.request_start); |
447 EXPECT_EQ(base::TimeTicks(), | 440 EXPECT_EQ(base::TimeTicks(), |
448 response_info().load_timing.connect_timing.dns_start); | 441 response_info().load_timing.connect_timing.dns_start); |
449 } | 442 } |
450 | 443 |
451 } // namespace content | 444 } // namespace content |
OLD | NEW |