| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 #include <utility> |
| 7 | 8 |
| 8 #include "base/bind.h" | 9 #include "base/bind.h" |
| 9 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 10 #include "base/files/file.h" | 11 #include "base/files/file.h" |
| 11 #include "base/files/file_enumerator.h" | 12 #include "base/files/file_enumerator.h" |
| 12 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
| 13 #include "base/files/file_util.h" | 14 #include "base/files/file_util.h" |
| 14 #include "base/lazy_instance.h" | 15 #include "base/lazy_instance.h" |
| 15 #include "base/location.h" | 16 #include "base/location.h" |
| 16 #include "base/macros.h" | 17 #include "base/macros.h" |
| (...skipping 588 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 605 context->TaskRunner()->PostTask(FROM_HERE, | 606 context->TaskRunner()->PostTask(FROM_HERE, |
| 606 base::Bind(&CorruptIndexedDBDatabase, | 607 base::Bind(&CorruptIndexedDBDatabase, |
| 607 base::ConstRef(context), | 608 base::ConstRef(context), |
| 608 origin_url, | 609 origin_url, |
| 609 &signal_when_finished)); | 610 &signal_when_finished)); |
| 610 signal_when_finished.Wait(); | 611 signal_when_finished.Wait(); |
| 611 | 612 |
| 612 scoped_ptr<net::test_server::BasicHttpResponse> http_response( | 613 scoped_ptr<net::test_server::BasicHttpResponse> http_response( |
| 613 new net::test_server::BasicHttpResponse); | 614 new net::test_server::BasicHttpResponse); |
| 614 http_response->set_code(net::HTTP_OK); | 615 http_response->set_code(net::HTTP_OK); |
| 615 return http_response.Pass(); | 616 return std::move(http_response); |
| 616 } else if (request_path == "fail" && !request_query.empty()) { | 617 } else if (request_path == "fail" && !request_query.empty()) { |
| 617 FailClass failure_class = FAIL_CLASS_NOTHING; | 618 FailClass failure_class = FAIL_CLASS_NOTHING; |
| 618 FailMethod failure_method = FAIL_METHOD_NOTHING; | 619 FailMethod failure_method = FAIL_METHOD_NOTHING; |
| 619 int instance_num = 1; | 620 int instance_num = 1; |
| 620 int call_num = 1; | 621 int call_num = 1; |
| 621 std::string fail_class; | 622 std::string fail_class; |
| 622 std::string fail_method; | 623 std::string fail_method; |
| 623 | 624 |
| 624 url::Component query(0, request_query.length()), key_pos, value_pos; | 625 url::Component query(0, request_query.length()), key_pos, value_pos; |
| 625 while (url::ExtractQueryKeyValue( | 626 while (url::ExtractQueryKeyValue( |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 } | 670 } |
| 670 | 671 |
| 671 DCHECK_GE(instance_num, 1); | 672 DCHECK_GE(instance_num, 1); |
| 672 DCHECK_GE(call_num, 1); | 673 DCHECK_GE(call_num, 1); |
| 673 | 674 |
| 674 test->FailOperation(failure_class, failure_method, instance_num, call_num); | 675 test->FailOperation(failure_class, failure_method, instance_num, call_num); |
| 675 | 676 |
| 676 scoped_ptr<net::test_server::BasicHttpResponse> http_response( | 677 scoped_ptr<net::test_server::BasicHttpResponse> http_response( |
| 677 new net::test_server::BasicHttpResponse); | 678 new net::test_server::BasicHttpResponse); |
| 678 http_response->set_code(net::HTTP_OK); | 679 http_response->set_code(net::HTTP_OK); |
| 679 return http_response.Pass(); | 680 return std::move(http_response); |
| 680 } | 681 } |
| 681 | 682 |
| 682 // A request for a test resource | 683 // A request for a test resource |
| 683 base::FilePath resource_path = | 684 base::FilePath resource_path = |
| 684 content::GetTestFilePath("indexeddb", request_path.c_str()); | 685 content::GetTestFilePath("indexeddb", request_path.c_str()); |
| 685 scoped_ptr<net::test_server::BasicHttpResponse> http_response( | 686 scoped_ptr<net::test_server::BasicHttpResponse> http_response( |
| 686 new net::test_server::BasicHttpResponse); | 687 new net::test_server::BasicHttpResponse); |
| 687 http_response->set_code(net::HTTP_OK); | 688 http_response->set_code(net::HTTP_OK); |
| 688 std::string file_contents; | 689 std::string file_contents; |
| 689 if (!base::ReadFileToString(resource_path, &file_contents)) | 690 if (!base::ReadFileToString(resource_path, &file_contents)) |
| 690 return scoped_ptr<net::test_server::HttpResponse>(); | 691 return scoped_ptr<net::test_server::HttpResponse>(); |
| 691 http_response->set_content(file_contents); | 692 http_response->set_content(file_contents); |
| 692 return http_response.Pass(); | 693 return std::move(http_response); |
| 693 } | 694 } |
| 694 | 695 |
| 695 } // namespace | 696 } // namespace |
| 696 | 697 |
| 697 IN_PROC_BROWSER_TEST_P(IndexedDBBrowserTest, OperationOnCorruptedOpenDatabase) { | 698 IN_PROC_BROWSER_TEST_P(IndexedDBBrowserTest, OperationOnCorruptedOpenDatabase) { |
| 698 ASSERT_TRUE(embedded_test_server()->Started() || | 699 ASSERT_TRUE(embedded_test_server()->Started() || |
| 699 embedded_test_server()->Start()); | 700 embedded_test_server()->Start()); |
| 700 const GURL& origin_url = embedded_test_server()->base_url(); | 701 const GURL& origin_url = embedded_test_server()->base_url(); |
| 701 embedded_test_server()->RegisterRequestHandler( | 702 embedded_test_server()->RegisterRequestHandler( |
| 702 base::Bind(&CorruptDBRequestHandler, | 703 base::Bind(&CorruptDBRequestHandler, |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 846 command_line->AppendSwitch(switches::kSingleProcess); | 847 command_line->AppendSwitch(switches::kSingleProcess); |
| 847 } | 848 } |
| 848 }; | 849 }; |
| 849 | 850 |
| 850 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTestSingleProcess, | 851 IN_PROC_BROWSER_TEST_F(IndexedDBBrowserTestSingleProcess, |
| 851 RenderThreadShutdownTest) { | 852 RenderThreadShutdownTest) { |
| 852 SimpleTest(GetTestUrl("indexeddb", "shutdown_with_requests.html")); | 853 SimpleTest(GetTestUrl("indexeddb", "shutdown_with_requests.html")); |
| 853 } | 854 } |
| 854 | 855 |
| 855 } // namespace content | 856 } // namespace content |
| OLD | NEW |