Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(164)

Side by Side Diff: components/printing/service/pdf_compositor_service.cc

Issue 2919823004: Add error handling and unit test for pdf compositor service (Closed)
Patch Set: rebase Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 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 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 "components/printing/service/pdf_compositor_service.h" 5 #include "components/printing/service/pdf_compositor_service.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/lazy_instance.h" 9 #include "base/lazy_instance.h"
10 #include "base/memory/discardable_memory.h" 10 #include "base/memory/discardable_memory.h"
(...skipping 24 matching lines...) Expand all
35 : creator_(creator.empty() ? "Chromium" : creator), weak_factory_(this) {} 35 : creator_(creator.empty() ? "Chromium" : creator), weak_factory_(this) {}
36 36
37 PdfCompositorService::~PdfCompositorService() = default; 37 PdfCompositorService::~PdfCompositorService() = default;
38 38
39 // static 39 // static
40 std::unique_ptr<service_manager::Service> PdfCompositorService::Create( 40 std::unique_ptr<service_manager::Service> PdfCompositorService::Create(
41 const std::string& creator) { 41 const std::string& creator) {
42 return base::MakeUnique<printing::PdfCompositorService>(creator); 42 return base::MakeUnique<printing::PdfCompositorService>(creator);
43 } 43 }
44 44
45 void PdfCompositorService::OnStart() { 45 void PdfCompositorService::PrepareToStart() {
46 // Set up discardable memory manager. 46 // Set up discardable memory manager.
47 discardable_memory::mojom::DiscardableSharedMemoryManagerPtr manager_ptr; 47 discardable_memory::mojom::DiscardableSharedMemoryManagerPtr manager_ptr;
48 context()->connector()->BindInterface(content::mojom::kBrowserServiceName, 48 context()->connector()->BindInterface(content::mojom::kBrowserServiceName,
49 &manager_ptr); 49 &manager_ptr);
50 discardable_shared_memory_manager_ = base::MakeUnique< 50 discardable_shared_memory_manager_ = base::MakeUnique<
51 discardable_memory::ClientDiscardableSharedMemoryManager>( 51 discardable_memory::ClientDiscardableSharedMemoryManager>(
52 std::move(manager_ptr), content::UtilityThread::Get()->GetIOTaskRunner()); 52 std::move(manager_ptr), content::UtilityThread::Get()->GetIOTaskRunner());
53 DCHECK(discardable_shared_memory_manager_); 53 DCHECK(discardable_shared_memory_manager_);
54 base::DiscardableMemoryAllocator::SetInstance( 54 base::DiscardableMemoryAllocator::SetInstance(
55 discardable_shared_memory_manager_.get()); 55 discardable_shared_memory_manager_.get());
56 }
57
58 void PdfCompositorService::OnStart() {
59 PrepareToStart();
56 60
57 ref_factory_ = base::MakeUnique<service_manager::ServiceContextRefFactory>( 61 ref_factory_ = base::MakeUnique<service_manager::ServiceContextRefFactory>(
58 base::Bind(&service_manager::ServiceContext::RequestQuit, 62 base::Bind(&service_manager::ServiceContext::RequestQuit,
59 base::Unretained(context()))); 63 base::Unretained(context())));
60 registry_.AddInterface( 64 registry_.AddInterface(
61 base::Bind(&OnPdfCompositorRequest, creator_, ref_factory_.get())); 65 base::Bind(&OnPdfCompositorRequest, creator_, ref_factory_.get()));
62 } 66 }
63 67
64 void PdfCompositorService::OnBindInterface( 68 void PdfCompositorService::OnBindInterface(
65 const service_manager::BindSourceInfo& source_info, 69 const service_manager::BindSourceInfo& source_info,
66 const std::string& interface_name, 70 const std::string& interface_name,
67 mojo::ScopedMessagePipeHandle interface_pipe) { 71 mojo::ScopedMessagePipeHandle interface_pipe) {
68 registry_.BindInterface(interface_name, std::move(interface_pipe)); 72 registry_.BindInterface(interface_name, std::move(interface_pipe));
69 } 73 }
70 74
71 } // namespace printing 75 } // namespace printing
OLDNEW
« no previous file with comments | « components/printing/service/pdf_compositor_service.h ('k') | components/printing/service/pdf_compositor_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698