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

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: add missing header Created 3 years, 6 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 25 matching lines...) Expand all
36 : creator_(creator.empty() ? "Chromium" : creator), weak_factory_(this) {} 36 : creator_(creator.empty() ? "Chromium" : creator), weak_factory_(this) {}
37 37
38 PdfCompositorService::~PdfCompositorService() = default; 38 PdfCompositorService::~PdfCompositorService() = default;
39 39
40 // static 40 // static
41 std::unique_ptr<service_manager::Service> PdfCompositorService::Create( 41 std::unique_ptr<service_manager::Service> PdfCompositorService::Create(
42 const std::string& creator) { 42 const std::string& creator) {
43 return base::MakeUnique<printing::PdfCompositorService>(creator); 43 return base::MakeUnique<printing::PdfCompositorService>(creator);
44 } 44 }
45 45
46 void PdfCompositorService::OnStart() { 46 void PdfCompositorService::PrepareToStart() {
47 // Set up discardable memory manager. 47 // Set up discardable memory manager.
48 discardable_memory::mojom::DiscardableSharedMemoryManagerPtr manager_ptr; 48 discardable_memory::mojom::DiscardableSharedMemoryManagerPtr manager_ptr;
49 context()->connector()->BindInterface(content::mojom::kBrowserServiceName, 49 context()->connector()->BindInterface(content::mojom::kBrowserServiceName,
50 &manager_ptr); 50 &manager_ptr);
51 discardable_shared_memory_manager_ = base::MakeUnique< 51 discardable_shared_memory_manager_ = base::MakeUnique<
52 discardable_memory::ClientDiscardableSharedMemoryManager>( 52 discardable_memory::ClientDiscardableSharedMemoryManager>(
53 std::move(manager_ptr), content::UtilityThread::Get()->GetIOTaskRunner()); 53 std::move(manager_ptr), content::UtilityThread::Get()->GetIOTaskRunner());
54 DCHECK(discardable_shared_memory_manager_); 54 DCHECK(discardable_shared_memory_manager_);
55 base::DiscardableMemoryAllocator::SetInstance( 55 base::DiscardableMemoryAllocator::SetInstance(
56 discardable_shared_memory_manager_.get()); 56 discardable_shared_memory_manager_.get());
57 }
58
59 void PdfCompositorService::OnStart() {
60 PrepareToStart();
57 61
58 ref_factory_ = base::MakeUnique<service_manager::ServiceContextRefFactory>( 62 ref_factory_ = base::MakeUnique<service_manager::ServiceContextRefFactory>(
59 base::Bind(&service_manager::ServiceContext::RequestQuit, 63 base::Bind(&service_manager::ServiceContext::RequestQuit,
60 base::Unretained(context()))); 64 base::Unretained(context())));
61 registry_.AddInterface( 65 registry_.AddInterface(
62 base::Bind(&OnPdfCompositorRequest, creator_, ref_factory_.get())); 66 base::Bind(&OnPdfCompositorRequest, creator_, ref_factory_.get()));
63 } 67 }
64 68
65 void PdfCompositorService::OnBindInterface( 69 void PdfCompositorService::OnBindInterface(
66 const service_manager::BindSourceInfo& source_info, 70 const service_manager::BindSourceInfo& source_info,
67 const std::string& interface_name, 71 const std::string& interface_name,
68 mojo::ScopedMessagePipeHandle interface_pipe) { 72 mojo::ScopedMessagePipeHandle interface_pipe) {
69 registry_.BindInterface(source_info, interface_name, 73 registry_.BindInterface(source_info, interface_name,
70 std::move(interface_pipe)); 74 std::move(interface_pipe));
71 } 75 }
72 76
73 } // namespace printing 77 } // namespace printing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698