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

Side by Side Diff: chrome/browser/chromeos/arc/arc_print_service.cc

Issue 2357053002: Always use arc::InstanceHolder<T>::GetInstanceForMethod (Closed)
Patch Set: review Created 4 years, 3 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 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/arc_print_service.h" 5 #include "chrome/browser/chromeos/arc/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
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()->instance(); 70 arc_bridge_service()->print()->GetInstanceForMethod("Init");
71 if (!print_instance) { 71 if (!print_instance)
72 LOG(ERROR) << "OnPrintInstanceReady called, but no print instance found";
73 return; 72 return;
74 }
75
76 print_instance->Init(binding_.CreateInterfacePtrAndBind()); 73 print_instance->Init(binding_.CreateInterfacePtrAndBind());
77 } 74 }
78 75
79 void ArcPrintService::Print(mojo::ScopedHandle pdf_data) { 76 void ArcPrintService::Print(mojo::ScopedHandle pdf_data) {
80 if (!pdf_data.is_valid()) { 77 if (!pdf_data.is_valid()) {
81 LOG(ERROR) << "handle is invalid"; 78 LOG(ERROR) << "handle is invalid";
82 return; 79 return;
83 } 80 }
84 81
85 mojo::edk::ScopedPlatformHandle scoped_platform_handle; 82 mojo::edk::ScopedPlatformHandle scoped_platform_handle;
86 MojoResult mojo_result = mojo::edk::PassWrappedPlatformHandle( 83 MojoResult mojo_result = mojo::edk::PassWrappedPlatformHandle(
87 pdf_data.release().value(), &scoped_platform_handle); 84 pdf_data.release().value(), &scoped_platform_handle);
88 if (mojo_result != MOJO_RESULT_OK) { 85 if (mojo_result != MOJO_RESULT_OK) {
89 LOG(ERROR) << "PassWrappedPlatformHandle failed: " << mojo_result; 86 LOG(ERROR) << "PassWrappedPlatformHandle failed: " << mojo_result;
90 return; 87 return;
91 } 88 }
92 89
93 base::File file(scoped_platform_handle.release().handle); 90 base::File file(scoped_platform_handle.release().handle);
94 91
95 content::BrowserThread::PostTaskAndReplyWithResult( 92 content::BrowserThread::PostTaskAndReplyWithResult(
96 content::BrowserThread::FILE, FROM_HERE, 93 content::BrowserThread::FILE, FROM_HERE,
97 base::Bind(&SavePdf, base::Passed(&file)), base::Bind(&OpenPdf)); 94 base::Bind(&SavePdf, base::Passed(&file)), base::Bind(&OpenPdf));
98 } 95 }
99 96
100 } // namespace arc 97 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698