| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/files/file.h" | 7 #include "base/files/file.h" |
| 8 #include "base/files/file_enumerator.h" | 8 #include "base/files/file_enumerator.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 context->TaskRunner()->PostTask(FROM_HERE, | 497 context->TaskRunner()->PostTask(FROM_HERE, |
| 498 base::Bind(&CorruptIndexedDBDatabase, | 498 base::Bind(&CorruptIndexedDBDatabase, |
| 499 base::ConstRef(context), | 499 base::ConstRef(context), |
| 500 origin_url, | 500 origin_url, |
| 501 &signal_when_finished)); | 501 &signal_when_finished)); |
| 502 signal_when_finished.Wait(); | 502 signal_when_finished.Wait(); |
| 503 | 503 |
| 504 scoped_ptr<net::test_server::BasicHttpResponse> http_response( | 504 scoped_ptr<net::test_server::BasicHttpResponse> http_response( |
| 505 new net::test_server::BasicHttpResponse); | 505 new net::test_server::BasicHttpResponse); |
| 506 http_response->set_code(net::HTTP_OK); | 506 http_response->set_code(net::HTTP_OK); |
| 507 return http_response.PassAs<net::test_server::HttpResponse>(); | 507 return http_response.Pass(); |
| 508 } else if (request_path == "fail" && !request_query.empty()) { | 508 } else if (request_path == "fail" && !request_query.empty()) { |
| 509 FailClass failure_class = FAIL_CLASS_NOTHING; | 509 FailClass failure_class = FAIL_CLASS_NOTHING; |
| 510 FailMethod failure_method = FAIL_METHOD_NOTHING; | 510 FailMethod failure_method = FAIL_METHOD_NOTHING; |
| 511 int instance_num = 1; | 511 int instance_num = 1; |
| 512 int call_num = 1; | 512 int call_num = 1; |
| 513 std::string fail_class; | 513 std::string fail_class; |
| 514 std::string fail_method; | 514 std::string fail_method; |
| 515 | 515 |
| 516 url::Component query(0, request_query.length()), key_pos, value_pos; | 516 url::Component query(0, request_query.length()), key_pos, value_pos; |
| 517 while (url::ExtractQueryKeyValue( | 517 while (url::ExtractQueryKeyValue( |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 561 } | 561 } |
| 562 | 562 |
| 563 DCHECK_GE(instance_num, 1); | 563 DCHECK_GE(instance_num, 1); |
| 564 DCHECK_GE(call_num, 1); | 564 DCHECK_GE(call_num, 1); |
| 565 | 565 |
| 566 test->FailOperation(failure_class, failure_method, instance_num, call_num); | 566 test->FailOperation(failure_class, failure_method, instance_num, call_num); |
| 567 | 567 |
| 568 scoped_ptr<net::test_server::BasicHttpResponse> http_response( | 568 scoped_ptr<net::test_server::BasicHttpResponse> http_response( |
| 569 new net::test_server::BasicHttpResponse); | 569 new net::test_server::BasicHttpResponse); |
| 570 http_response->set_code(net::HTTP_OK); | 570 http_response->set_code(net::HTTP_OK); |
| 571 return http_response.PassAs<net::test_server::HttpResponse>(); | 571 return http_response.Pass(); |
| 572 } | 572 } |
| 573 | 573 |
| 574 // A request for a test resource | 574 // A request for a test resource |
| 575 base::FilePath resourcePath = | 575 base::FilePath resourcePath = |
| 576 content::GetTestFilePath("indexeddb", request_path.c_str()); | 576 content::GetTestFilePath("indexeddb", request_path.c_str()); |
| 577 scoped_ptr<net::test_server::BasicHttpResponse> http_response( | 577 scoped_ptr<net::test_server::BasicHttpResponse> http_response( |
| 578 new net::test_server::BasicHttpResponse); | 578 new net::test_server::BasicHttpResponse); |
| 579 http_response->set_code(net::HTTP_OK); | 579 http_response->set_code(net::HTTP_OK); |
| 580 std::string file_contents; | 580 std::string file_contents; |
| 581 if (!base::ReadFileToString(resourcePath, &file_contents)) | 581 if (!base::ReadFileToString(resourcePath, &file_contents)) |
| 582 return scoped_ptr<net::test_server::HttpResponse>(); | 582 return scoped_ptr<net::test_server::HttpResponse>(); |
| 583 http_response->set_content(file_contents); | 583 http_response->set_content(file_contents); |
| 584 return http_response.PassAs<net::test_server::HttpResponse>(); | 584 return http_response.Pass(); |
| 585 } | 585 } |
| 586 | 586 |
| 587 } // namespace | 587 } // namespace |
| 588 | 588 |
| 589 class IndexedDBBrowserCorruptionTest | 589 class IndexedDBBrowserCorruptionTest |
| 590 : public IndexedDBBrowserTest, | 590 : public IndexedDBBrowserTest, |
| 591 public ::testing::WithParamInterface<const char*> {}; | 591 public ::testing::WithParamInterface<const char*> {}; |
| 592 | 592 |
| 593 IN_PROC_BROWSER_TEST_P(IndexedDBBrowserCorruptionTest, | 593 IN_PROC_BROWSER_TEST_P(IndexedDBBrowserCorruptionTest, |
| 594 OperationOnCorruptedOpenDatabase) { | 594 OperationOnCorruptedOpenDatabase) { |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 727 command_line->AppendSwitch(switches::kSingleProcess); | 727 command_line->AppendSwitch(switches::kSingleProcess); |
| 728 } | 728 } |
| 729 }; | 729 }; |
| 730 | 730 |
| 731 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTestSingleProcess, | 731 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTestSingleProcess, |
| 732 RenderThreadShutdownTest) { | 732 RenderThreadShutdownTest) { |
| 733 SimpleTest(GetTestUrl("indexeddb", "shutdown_with_requests.html")); | 733 SimpleTest(GetTestUrl("indexeddb", "shutdown_with_requests.html")); |
| 734 } | 734 } |
| 735 | 735 |
| 736 } // namespace content | 736 } // namespace content |
| OLD | NEW |