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

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: Fixed cpplint warnings. Created 5 years, 9 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 <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 if (!event_router->ExtensionHasEventListener( 464 if (!event_router->ExtensionHasEventListener(
465 extension_id, 465 extension_id,
466 core_api::printer_provider::OnPrintRequested::kEventName)) { 466 core_api::printer_provider::OnPrintRequested::kEventName)) {
467 callback.Run(false, PrinterProviderAPI::GetDefaultPrintError()); 467 callback.Run(false, PrinterProviderAPI::GetDefaultPrintError());
468 return; 468 return;
469 } 469 }
470 470
471 core_api::printer_provider::PrintJob print_job; 471 core_api::printer_provider::PrintJob print_job;
472 print_job.printer_id = internal_printer_id; 472 print_job.printer_id = internal_printer_id;
473 473
474 JSONStringValueSerializer serializer(job.ticket_json); 474 JSONStringValueDeserializer deserializer(job.ticket_json);
475 scoped_ptr<base::Value> ticket_value(serializer.Deserialize(NULL, NULL)); 475 scoped_ptr<base::Value> ticket_value(deserializer.Deserialize(NULL, NULL));
476 if (!ticket_value || 476 if (!ticket_value ||
477 !core_api::printer_provider::PrintJob::Ticket::Populate( 477 !core_api::printer_provider::PrintJob::Ticket::Populate(
478 *ticket_value, &print_job.ticket)) { 478 *ticket_value, &print_job.ticket)) {
479 callback.Run(false, 479 callback.Run(false,
480 core_api::printer_provider::ToString( 480 core_api::printer_provider::ToString(
481 core_api::printer_provider::PRINT_ERROR_INVALID_TICKET)); 481 core_api::printer_provider::PRINT_ERROR_INVALID_TICKET));
482 return; 482 return;
483 } 483 }
484 484
485 // TODO(tbarzic): Figure out how to support huge documents. 485 // TODO(tbarzic): Figure out how to support huge documents.
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 return new PrinterProviderAPIImpl(context); 595 return new PrinterProviderAPIImpl(context);
596 } 596 }
597 597
598 // static 598 // static
599 std::string PrinterProviderAPI::GetDefaultPrintError() { 599 std::string PrinterProviderAPI::GetDefaultPrintError() {
600 return core_api::printer_provider_internal::ToString( 600 return core_api::printer_provider_internal::ToString(
601 core_api::printer_provider_internal::PRINT_ERROR_FAILED); 601 core_api::printer_provider_internal::PRINT_ERROR_FAILED);
602 } 602 }
603 603
604 } // namespace extensions 604 } // namespace extensions
OLDNEW
« no previous file with comments | « components/update_client/component_unpacker.cc ('k') | extensions/browser/api/printer_provider/printer_provider_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698