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

Side by Side Diff: extensions/browser/api/printer_provider_internal/printer_provider_internal_api.cc

Issue 2424593002: Reduce FOR_EACH_OBSERVER usage in extensions (Closed)
Patch Set: script_observers_ Created 4 years, 2 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "extensions/browser/api/printer_provider_internal/printer_provider_inte rnal_api.h" 5 #include "extensions/browser/api/printer_provider_internal/printer_provider_inte rnal_api.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 60
61 void PrinterProviderInternalAPI::RemoveObserver( 61 void PrinterProviderInternalAPI::RemoveObserver(
62 PrinterProviderInternalAPIObserver* observer) { 62 PrinterProviderInternalAPIObserver* observer) {
63 observers_.RemoveObserver(observer); 63 observers_.RemoveObserver(observer);
64 } 64 }
65 65
66 void PrinterProviderInternalAPI::NotifyGetPrintersResult( 66 void PrinterProviderInternalAPI::NotifyGetPrintersResult(
67 const Extension* extension, 67 const Extension* extension,
68 int request_id, 68 int request_id,
69 const PrinterProviderInternalAPIObserver::PrinterInfoVector& printers) { 69 const PrinterProviderInternalAPIObserver::PrinterInfoVector& printers) {
70 FOR_EACH_OBSERVER(PrinterProviderInternalAPIObserver, observers_, 70 for (auto& observer : observers_)
71 OnGetPrintersResult(extension, request_id, printers)); 71 observer.OnGetPrintersResult(extension, request_id, printers);
72 } 72 }
73 73
74 void PrinterProviderInternalAPI::NotifyGetCapabilityResult( 74 void PrinterProviderInternalAPI::NotifyGetCapabilityResult(
75 const Extension* extension, 75 const Extension* extension,
76 int request_id, 76 int request_id,
77 const base::DictionaryValue& capability) { 77 const base::DictionaryValue& capability) {
78 FOR_EACH_OBSERVER(PrinterProviderInternalAPIObserver, observers_, 78 for (auto& observer : observers_)
79 OnGetCapabilityResult(extension, request_id, capability)); 79 observer.OnGetCapabilityResult(extension, request_id, capability);
80 } 80 }
81 81
82 void PrinterProviderInternalAPI::NotifyPrintResult( 82 void PrinterProviderInternalAPI::NotifyPrintResult(
83 const Extension* extension, 83 const Extension* extension,
84 int request_id, 84 int request_id,
85 api::printer_provider_internal::PrintError error) { 85 api::printer_provider_internal::PrintError error) {
86 FOR_EACH_OBSERVER(PrinterProviderInternalAPIObserver, observers_, 86 for (auto& observer : observers_)
87 OnPrintResult(extension, request_id, error)); 87 observer.OnPrintResult(extension, request_id, error);
88 } 88 }
89 89
90 void PrinterProviderInternalAPI::NotifyGetUsbPrinterInfoResult( 90 void PrinterProviderInternalAPI::NotifyGetUsbPrinterInfoResult(
91 const Extension* extension, 91 const Extension* extension,
92 int request_id, 92 int request_id,
93 const api::printer_provider::PrinterInfo* printer_info) { 93 const api::printer_provider::PrinterInfo* printer_info) {
94 FOR_EACH_OBSERVER( 94 for (auto& observer : observers_)
95 PrinterProviderInternalAPIObserver, observers_, 95 observer.OnGetUsbPrinterInfoResult(extension, request_id, printer_info);
96 OnGetUsbPrinterInfoResult(extension, request_id, printer_info));
97 } 96 }
98 97
99 PrinterProviderInternalReportPrintResultFunction:: 98 PrinterProviderInternalReportPrintResultFunction::
100 PrinterProviderInternalReportPrintResultFunction() { 99 PrinterProviderInternalReportPrintResultFunction() {
101 } 100 }
102 101
103 PrinterProviderInternalReportPrintResultFunction:: 102 PrinterProviderInternalReportPrintResultFunction::
104 ~PrinterProviderInternalReportPrintResultFunction() { 103 ~PrinterProviderInternalReportPrintResultFunction() {
105 } 104 }
106 105
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 EXTENSION_FUNCTION_VALIDATE(params.get()); 258 EXTENSION_FUNCTION_VALIDATE(params.get());
260 259
261 PrinterProviderInternalAPI::GetFactoryInstance() 260 PrinterProviderInternalAPI::GetFactoryInstance()
262 ->Get(browser_context()) 261 ->Get(browser_context())
263 ->NotifyGetUsbPrinterInfoResult(extension(), params->request_id, 262 ->NotifyGetUsbPrinterInfoResult(extension(), params->request_id,
264 params->printer_info.get()); 263 params->printer_info.get());
265 return RespondNow(NoArguments()); 264 return RespondNow(NoArguments());
266 } 265 }
267 266
268 } // namespace extensions 267 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698