OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/browser/dom_storage/local_storage_context_mojo.h" | 5 #include "content/browser/dom_storage/local_storage_context_mojo.h" |
6 | 6 |
7 #include "base/files/file_enumerator.h" | 7 #include "base/files/file_enumerator.h" |
8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 } | 610 } |
611 | 611 |
612 namespace { | 612 namespace { |
613 | 613 |
614 class ServiceTestClient : public service_manager::test::ServiceTestClient, | 614 class ServiceTestClient : public service_manager::test::ServiceTestClient, |
615 public service_manager::mojom::ServiceFactory, | 615 public service_manager::mojom::ServiceFactory, |
616 public service_manager::InterfaceFactory< | 616 public service_manager::InterfaceFactory< |
617 service_manager::mojom::ServiceFactory> { | 617 service_manager::mojom::ServiceFactory> { |
618 public: | 618 public: |
619 explicit ServiceTestClient(service_manager::test::ServiceTest* test) | 619 explicit ServiceTestClient(service_manager::test::ServiceTest* test) |
620 : service_manager::test::ServiceTestClient(test) {} | 620 : service_manager::test::ServiceTestClient(test) { |
| 621 registry_.AddInterface<service_manager::mojom::ServiceFactory>(this); |
| 622 } |
621 ~ServiceTestClient() override {} | 623 ~ServiceTestClient() override {} |
622 | 624 |
623 protected: | 625 protected: |
624 bool OnConnect(const service_manager::ServiceInfo& remote_info, | 626 void OnBindInterface(const service_manager::ServiceInfo& source_info, |
625 service_manager::InterfaceRegistry* registry) override { | 627 const std::string& interface_name, |
626 registry->AddInterface<service_manager::mojom::ServiceFactory>(this); | 628 mojo::ScopedMessagePipeHandle interface_pipe) override { |
627 return true; | 629 registry_.BindInterface(source_info.identity, interface_name, |
| 630 std::move(interface_pipe)); |
628 } | 631 } |
629 | 632 |
630 void CreateService(service_manager::mojom::ServiceRequest request, | 633 void CreateService(service_manager::mojom::ServiceRequest request, |
631 const std::string& name) override { | 634 const std::string& name) override { |
632 if (name == file::mojom::kServiceName) { | 635 if (name == file::mojom::kServiceName) { |
633 file_service_context_.reset(new service_manager::ServiceContext( | 636 file_service_context_.reset(new service_manager::ServiceContext( |
634 file::CreateFileService( | 637 file::CreateFileService( |
635 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE), | 638 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE), |
636 BrowserThread::GetTaskRunnerForThread(BrowserThread::DB)), | 639 BrowserThread::GetTaskRunnerForThread(BrowserThread::DB)), |
637 std::move(request))); | 640 std::move(request))); |
638 } | 641 } |
639 } | 642 } |
640 | 643 |
641 void Create(const service_manager::Identity& remote_identity, | 644 void Create(const service_manager::Identity& remote_identity, |
642 service_manager::mojom::ServiceFactoryRequest request) override { | 645 service_manager::mojom::ServiceFactoryRequest request) override { |
643 service_factory_bindings_.AddBinding(this, std::move(request)); | 646 service_factory_bindings_.AddBinding(this, std::move(request)); |
644 } | 647 } |
645 | 648 |
646 private: | 649 private: |
| 650 service_manager::BinderRegistry registry_; |
647 mojo::BindingSet<service_manager::mojom::ServiceFactory> | 651 mojo::BindingSet<service_manager::mojom::ServiceFactory> |
648 service_factory_bindings_; | 652 service_factory_bindings_; |
649 std::unique_ptr<service_manager::ServiceContext> file_service_context_; | 653 std::unique_ptr<service_manager::ServiceContext> file_service_context_; |
650 }; | 654 }; |
651 | 655 |
652 } // namespace | 656 } // namespace |
653 | 657 |
654 class LocalStorageContextMojoTestWithService | 658 class LocalStorageContextMojoTestWithService |
655 : public service_manager::test::ServiceTest { | 659 : public service_manager::test::ServiceTest { |
656 public: | 660 public: |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
837 base::RunLoop().RunUntilIdle(); | 841 base::RunLoop().RunUntilIdle(); |
838 | 842 |
839 // Data should have been preserved now. | 843 // Data should have been preserved now. |
840 context = base::MakeUnique<LocalStorageContextMojo>( | 844 context = base::MakeUnique<LocalStorageContextMojo>( |
841 connector(), nullptr, base::FilePath(), test_path); | 845 connector(), nullptr, base::FilePath(), test_path); |
842 EXPECT_TRUE(DoTestGet(context.get(), key, &result)); | 846 EXPECT_TRUE(DoTestGet(context.get(), key, &result)); |
843 EXPECT_EQ(value, result); | 847 EXPECT_EQ(value, result); |
844 } | 848 } |
845 | 849 |
846 } // namespace content | 850 } // namespace content |
OLD | NEW |