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

Side by Side Diff: cloud_print/gcp20/prototype/privet_http_server.cc

Issue 1552613003: Remove needless move() calls in cloud_print/gcp20 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « cloud_print/gcp20/prototype/cloud_print_url_request_context_getter.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "cloud_print/gcp20/prototype/privet_http_server.h" 5 #include "cloud_print/gcp20/prototype/privet_http_server.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <utility> 9 #include <utility>
10 10
(...skipping 17 matching lines...) Expand all
28 const char kPrivetCapabilities[] = "/privet/capabilities"; 28 const char kPrivetCapabilities[] = "/privet/capabilities";
29 const char kPrivetPrinterCreateJob[] = "/privet/printer/createjob"; 29 const char kPrivetPrinterCreateJob[] = "/privet/printer/createjob";
30 const char kPrivetPrinterSubmitDoc[] = "/privet/printer/submitdoc"; 30 const char kPrivetPrinterSubmitDoc[] = "/privet/printer/submitdoc";
31 const char kPrivetPrinterJobState[] = "/privet/printer/jobstate"; 31 const char kPrivetPrinterJobState[] = "/privet/printer/jobstate";
32 32
33 // {"error":|error_type|} 33 // {"error":|error_type|}
34 scoped_ptr<base::DictionaryValue> CreateError(const std::string& error_type) { 34 scoped_ptr<base::DictionaryValue> CreateError(const std::string& error_type) {
35 scoped_ptr<base::DictionaryValue> error(new base::DictionaryValue); 35 scoped_ptr<base::DictionaryValue> error(new base::DictionaryValue);
36 error->SetString("error", error_type); 36 error->SetString("error", error_type);
37 37
38 return std::move(error); 38 return error;
39 } 39 }
40 40
41 // {"error":|error_type|, "description":|description|} 41 // {"error":|error_type|, "description":|description|}
42 scoped_ptr<base::DictionaryValue> CreateErrorWithDescription( 42 scoped_ptr<base::DictionaryValue> CreateErrorWithDescription(
43 const std::string& error_type, 43 const std::string& error_type,
44 const std::string& description) { 44 const std::string& description) {
45 scoped_ptr<base::DictionaryValue> error(CreateError(error_type)); 45 scoped_ptr<base::DictionaryValue> error(CreateError(error_type));
46 error->SetString("description", description); 46 error->SetString("description", description);
47 return std::move(error); 47 return error;
48 } 48 }
49 49
50 // {"error":|error_type|, "timeout":|timeout|} 50 // {"error":|error_type|, "timeout":|timeout|}
51 scoped_ptr<base::DictionaryValue> CreateErrorWithTimeout( 51 scoped_ptr<base::DictionaryValue> CreateErrorWithTimeout(
52 const std::string& error_type, 52 const std::string& error_type,
53 int timeout) { 53 int timeout) {
54 scoped_ptr<base::DictionaryValue> error(CreateError(error_type)); 54 scoped_ptr<base::DictionaryValue> error(CreateError(error_type));
55 error->SetInteger("timeout", timeout); 55 error->SetInteger("timeout", timeout);
56 return std::move(error); 56 return error;
57 } 57 }
58 58
59 // Converts state to string. 59 // Converts state to string.
60 std::string LocalPrintJobStateToString(LocalPrintJob::State state) { 60 std::string LocalPrintJobStateToString(LocalPrintJob::State state) {
61 switch (state) { 61 switch (state) {
62 case LocalPrintJob::STATE_DRAFT: 62 case LocalPrintJob::STATE_DRAFT:
63 return "draft"; 63 return "draft";
64 break; 64 break;
65 case LocalPrintJob::STATE_ABORTED: 65 case LocalPrintJob::STATE_ABORTED:
66 return "done"; 66 return "done";
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 for (size_t i = 0; i < info.api.size(); ++i) 271 for (size_t i = 0; i < info.api.size(); ++i)
272 api.AppendString(info.api[i]); 272 api.AppendString(info.api[i]);
273 response->Set("api", api.DeepCopy()); 273 response->Set("api", api.DeepCopy());
274 274
275 base::ListValue type; 275 base::ListValue type;
276 for (size_t i = 0; i < info.type.size(); ++i) 276 for (size_t i = 0; i < info.type.size(); ++i)
277 type.AppendString(info.type[i]); 277 type.AppendString(info.type[i]);
278 response->Set("type", type.DeepCopy()); 278 response->Set("type", type.DeepCopy());
279 279
280 *status_code = net::HTTP_OK; 280 *status_code = net::HTTP_OK;
281 return std::move(response); 281 return response;
282 } 282 }
283 283
284 scoped_ptr<base::DictionaryValue> PrivetHttpServer::ProcessCapabilities( 284 scoped_ptr<base::DictionaryValue> PrivetHttpServer::ProcessCapabilities(
285 net::HttpStatusCode* status_code) const { 285 net::HttpStatusCode* status_code) const {
286 if (!delegate_->IsRegistered()) { 286 if (!delegate_->IsRegistered()) {
287 *status_code = net::HTTP_NOT_FOUND; 287 *status_code = net::HTTP_NOT_FOUND;
288 return scoped_ptr<base::DictionaryValue>(); 288 return scoped_ptr<base::DictionaryValue>();
289 } 289 }
290 return make_scoped_ptr(delegate_->GetCapabilities().DeepCopy()); 290 return make_scoped_ptr(delegate_->GetCapabilities().DeepCopy());
291 } 291 }
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 switch (status) { 370 switch (status) {
371 case LocalPrintJob::SAVE_SUCCESS: 371 case LocalPrintJob::SAVE_SUCCESS:
372 response->SetString("job_id", job_id); 372 response->SetString("job_id", job_id);
373 response->SetInteger("expires_in", expires_in); 373 response->SetInteger("expires_in", expires_in);
374 response->SetString("job_type", job.content_type); 374 response->SetString("job_type", job.content_type);
375 response->SetString( 375 response->SetString(
376 "job_size", 376 "job_size",
377 base::StringPrintf("%u", static_cast<uint32_t>(job.content.size()))); 377 base::StringPrintf("%u", static_cast<uint32_t>(job.content.size())));
378 if (job_name_present) 378 if (job_name_present)
379 response->SetString("job_name", job.job_name); 379 response->SetString("job_name", job.job_name);
380 return std::move(response); 380 return response;
381 381
382 case LocalPrintJob::SAVE_INVALID_PRINT_JOB: 382 case LocalPrintJob::SAVE_INVALID_PRINT_JOB:
383 return CreateErrorWithTimeout("invalid_print_job", timeout); 383 return CreateErrorWithTimeout("invalid_print_job", timeout);
384 case LocalPrintJob::SAVE_INVALID_DOCUMENT_TYPE: 384 case LocalPrintJob::SAVE_INVALID_DOCUMENT_TYPE:
385 return CreateError("invalid_document_type"); 385 return CreateError("invalid_document_type");
386 case LocalPrintJob::SAVE_INVALID_DOCUMENT: 386 case LocalPrintJob::SAVE_INVALID_DOCUMENT:
387 return CreateError("invalid_document"); 387 return CreateError("invalid_document");
388 case LocalPrintJob::SAVE_DOCUMENT_TOO_LARGE: 388 case LocalPrintJob::SAVE_DOCUMENT_TOO_LARGE:
389 return CreateError("document_too_large"); 389 return CreateError("document_too_large");
390 case LocalPrintJob::SAVE_PRINTER_BUSY: 390 case LocalPrintJob::SAVE_PRINTER_BUSY:
(...skipping 17 matching lines...) Expand all
408 std::string job_id; 408 std::string job_id;
409 net::GetValueForKeyInQuery(url, "job_id", &job_id); 409 net::GetValueForKeyInQuery(url, "job_id", &job_id);
410 LocalPrintJob::Info info; 410 LocalPrintJob::Info info;
411 if (!delegate_->GetJobState(job_id, &info)) 411 if (!delegate_->GetJobState(job_id, &info))
412 return CreateError("invalid_print_job"); 412 return CreateError("invalid_print_job");
413 413
414 scoped_ptr<base::DictionaryValue> response(new base::DictionaryValue); 414 scoped_ptr<base::DictionaryValue> response(new base::DictionaryValue);
415 response->SetString("job_id", job_id); 415 response->SetString("job_id", job_id);
416 response->SetString("state", LocalPrintJobStateToString(info.state)); 416 response->SetString("state", LocalPrintJobStateToString(info.state));
417 response->SetInteger("expires_in", info.expires_in); 417 response->SetInteger("expires_in", info.expires_in);
418 return std::move(response); 418 return response;
419 } 419 }
420 420
421 scoped_ptr<base::DictionaryValue> PrivetHttpServer::ProcessRegister( 421 scoped_ptr<base::DictionaryValue> PrivetHttpServer::ProcessRegister(
422 const GURL& url, 422 const GURL& url,
423 net::HttpStatusCode* status_code) const { 423 net::HttpStatusCode* status_code) const {
424 if (delegate_->IsRegistered()) { 424 if (delegate_->IsRegistered()) {
425 *status_code = net::HTTP_NOT_FOUND; 425 *status_code = net::HTTP_NOT_FOUND;
426 return scoped_ptr<base::DictionaryValue>(); 426 return scoped_ptr<base::DictionaryValue>();
427 } 427 }
428 428
(...skipping 30 matching lines...) Expand all
459 459
460 if (action == "cancel") 460 if (action == "cancel")
461 status = delegate_->RegistrationCancel(user); 461 status = delegate_->RegistrationCancel(user);
462 } 462 }
463 463
464 if (status != REG_ERROR_OK) 464 if (status != REG_ERROR_OK)
465 response.reset(); 465 response.reset();
466 466
467 ProcessRegistrationStatus(status, &response); 467 ProcessRegistrationStatus(status, &response);
468 *status_code = net::HTTP_OK; 468 *status_code = net::HTTP_OK;
469 return std::move(response); 469 return response;
470 } 470 }
471 471
472 void PrivetHttpServer::ProcessRegistrationStatus( 472 void PrivetHttpServer::ProcessRegistrationStatus(
473 RegistrationErrorStatus status, 473 RegistrationErrorStatus status,
474 scoped_ptr<base::DictionaryValue>* current_response) const { 474 scoped_ptr<base::DictionaryValue>* current_response) const {
475 switch (status) { 475 switch (status) {
476 case REG_ERROR_OK: 476 case REG_ERROR_OK:
477 DCHECK(*current_response) << "Response shouldn't be empty."; 477 DCHECK(*current_response) << "Response shouldn't be empty.";
478 break; 478 break;
479 479
(...skipping 26 matching lines...) Expand all
506 delegate_->GetRegistrationServerError(&description); 506 delegate_->GetRegistrationServerError(&description);
507 *current_response = CreateErrorWithDescription("server_error", 507 *current_response = CreateErrorWithDescription("server_error",
508 description); 508 description);
509 break; 509 break;
510 } 510 }
511 511
512 default: 512 default:
513 NOTREACHED(); 513 NOTREACHED();
514 }; 514 };
515 } 515 }
OLDNEW
« no previous file with comments | « cloud_print/gcp20/prototype/cloud_print_url_request_context_getter.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698