OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "base/test/test_discardable_memory_allocator.h" |
| 6 #include "components/printing/service/pdf_compositor_service.h" |
| 7 #include "services/service_manager/public/c/main.h" |
| 8 #include "services/service_manager/public/cpp/service_runner.h" |
| 9 |
| 10 // In order to test PdfCompositorService, this class overrides and |
| 11 // uses a test discardable memory allocator. |
| 12 class PdfCompositorTestService : public printing::PdfCompositorService { |
| 13 public: |
| 14 explicit PdfCompositorTestService(const std::string& creator) |
| 15 : PdfCompositorService(creator) {} |
| 16 ~PdfCompositorTestService() override {} |
| 17 |
| 18 // PdfCompositorService: |
| 19 void PrepareToStart() override; |
| 20 |
| 21 private: |
| 22 base::TestDiscardableMemoryAllocator mem_allocator_; |
| 23 }; |
| 24 |
| 25 void PdfCompositorTestService::PrepareToStart() { |
| 26 base::DiscardableMemoryAllocator::SetInstance(&mem_allocator_); |
| 27 } |
| 28 |
| 29 MojoResult ServiceMain(MojoHandle service_request_handle) { |
| 30 service_manager::ServiceRunner runner( |
| 31 new PdfCompositorTestService("pdf_compositor_service_unittest")); |
| 32 return runner.Run(service_request_handle); |
| 33 } |
OLD | NEW |