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

Side by Side Diff: extensions/browser/api/printer_provider/printer_provider_api.cc

Issue 925783002: Split ValueSerializer into separate Serializer and Deserializer classes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated as per review comments. Created 5 years, 10 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/printer_provider_api.h" 5 #include "extensions/browser/api/printer_provider/printer_provider_api.h"
6 6
7 #include <utility> 7 #include <utility>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 if (!event_router->ExtensionHasEventListener( 166 if (!event_router->ExtensionHasEventListener(
167 extension_id, 167 extension_id,
168 core_api::printer_provider::OnPrintRequested::kEventName)) { 168 core_api::printer_provider::OnPrintRequested::kEventName)) {
169 callback.Run(false, GetDefaultPrintError()); 169 callback.Run(false, GetDefaultPrintError());
170 return; 170 return;
171 } 171 }
172 172
173 core_api::printer_provider::PrintJob print_job; 173 core_api::printer_provider::PrintJob print_job;
174 print_job.printer_id = internal_printer_id; 174 print_job.printer_id = internal_printer_id;
175 175
176 JSONStringValueSerializer serializer(job.ticket_json); 176 JSONStringValueDeserializer deserializer(job.ticket_json);
177 scoped_ptr<base::Value> ticket_value(serializer.Deserialize(NULL, NULL)); 177 scoped_ptr<base::Value> ticket_value(deserializer.Deserialize(NULL, NULL));
178 if (!ticket_value || 178 if (!ticket_value ||
179 !core_api::printer_provider::PrintJob::Ticket::Populate( 179 !core_api::printer_provider::PrintJob::Ticket::Populate(
180 *ticket_value, &print_job.ticket)) { 180 *ticket_value, &print_job.ticket)) {
181 callback.Run(false, 181 callback.Run(false,
182 core_api::printer_provider::ToString( 182 core_api::printer_provider::ToString(
183 core_api::printer_provider::PRINT_ERROR_INVALID_TICKET)); 183 core_api::printer_provider::PRINT_ERROR_INVALID_TICKET));
184 return; 184 return;
185 } 185 }
186 186
187 // TODO(tbarzic): Figure out how to support huge documents. 187 // TODO(tbarzic): Figure out how to support huge documents.
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 435
436 template <> 436 template <>
437 void BrowserContextKeyedAPIFactory< 437 void BrowserContextKeyedAPIFactory<
438 PrinterProviderAPI>::DeclareFactoryDependencies() { 438 PrinterProviderAPI>::DeclareFactoryDependencies() {
439 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); 439 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory());
440 DependsOn(PrinterProviderInternalAPI::GetFactoryInstance()); 440 DependsOn(PrinterProviderInternalAPI::GetFactoryInstance());
441 DependsOn(ExtensionRegistryFactory::GetInstance()); 441 DependsOn(ExtensionRegistryFactory::GetInstance());
442 } 442 }
443 443
444 } // namespace extensions 444 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698