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 "chrome/browser/chromeos/arc/print/arc_print_service.h" | 5 #include "chrome/browser/chromeos/arc/print/arc_print_service.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "ash/common/shell_delegate.h" | 9 #include "ash/common/shell_delegate.h" |
10 #include "ash/common/wm_shell.h" | 10 #include "ash/common/wm_shell.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 : ArcService(bridge_service), binding_(this) { | 60 : ArcService(bridge_service), binding_(this) { |
61 arc_bridge_service()->print()->AddObserver(this); | 61 arc_bridge_service()->print()->AddObserver(this); |
62 } | 62 } |
63 | 63 |
64 ArcPrintService::~ArcPrintService() { | 64 ArcPrintService::~ArcPrintService() { |
65 arc_bridge_service()->print()->RemoveObserver(this); | 65 arc_bridge_service()->print()->RemoveObserver(this); |
66 } | 66 } |
67 | 67 |
68 void ArcPrintService::OnInstanceReady() { | 68 void ArcPrintService::OnInstanceReady() { |
69 mojom::PrintInstance* print_instance = | 69 mojom::PrintInstance* print_instance = |
70 arc_bridge_service()->print()->GetInstanceForMethod("Init"); | 70 ARC_GET_INSTANCE_FOR_METHOD(arc_bridge_service()->print(), Init); |
71 DCHECK(print_instance); | 71 DCHECK(print_instance); |
72 print_instance->Init(binding_.CreateInterfacePtrAndBind()); | 72 print_instance->Init(binding_.CreateInterfacePtrAndBind()); |
73 } | 73 } |
74 | 74 |
75 void ArcPrintService::Print(mojo::ScopedHandle pdf_data) { | 75 void ArcPrintService::Print(mojo::ScopedHandle pdf_data) { |
76 if (!pdf_data.is_valid()) { | 76 if (!pdf_data.is_valid()) { |
77 LOG(ERROR) << "handle is invalid"; | 77 LOG(ERROR) << "handle is invalid"; |
78 return; | 78 return; |
79 } | 79 } |
80 | 80 |
81 mojo::edk::ScopedPlatformHandle scoped_platform_handle; | 81 mojo::edk::ScopedPlatformHandle scoped_platform_handle; |
82 MojoResult mojo_result = mojo::edk::PassWrappedPlatformHandle( | 82 MojoResult mojo_result = mojo::edk::PassWrappedPlatformHandle( |
83 pdf_data.release().value(), &scoped_platform_handle); | 83 pdf_data.release().value(), &scoped_platform_handle); |
84 if (mojo_result != MOJO_RESULT_OK) { | 84 if (mojo_result != MOJO_RESULT_OK) { |
85 LOG(ERROR) << "PassWrappedPlatformHandle failed: " << mojo_result; | 85 LOG(ERROR) << "PassWrappedPlatformHandle failed: " << mojo_result; |
86 return; | 86 return; |
87 } | 87 } |
88 | 88 |
89 base::File file(scoped_platform_handle.release().handle); | 89 base::File file(scoped_platform_handle.release().handle); |
90 | 90 |
91 content::BrowserThread::PostTaskAndReplyWithResult( | 91 content::BrowserThread::PostTaskAndReplyWithResult( |
92 content::BrowserThread::FILE, FROM_HERE, | 92 content::BrowserThread::FILE, FROM_HERE, |
93 base::Bind(&SavePdf, base::Passed(&file)), base::Bind(&OpenPdf)); | 93 base::Bind(&SavePdf, base::Passed(&file)), base::Bind(&OpenPdf)); |
94 } | 94 } |
95 | 95 |
96 } // namespace arc | 96 } // namespace arc |
OLD | NEW |