OLD | NEW |
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/cloud_print_request.h" | 5 #include "cloud_print/gcp20/prototype/cloud_print_request.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <utility> |
8 | 9 |
9 #include "base/bind.h" | 10 #include "base/bind.h" |
10 #include "base/command_line.h" | 11 #include "base/command_line.h" |
11 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
12 #include "base/strings/stringprintf.h" | 13 #include "base/strings/stringprintf.h" |
13 #include "base/time/time.h" | 14 #include "base/time/time.h" |
14 #include "net/base/load_flags.h" | 15 #include "net/base/load_flags.h" |
15 #include "net/http/http_status_code.h" | 16 #include "net/http/http_status_code.h" |
16 #include "net/url_request/url_request_context.h" | 17 #include "net/url_request/url_request_context.h" |
17 #include "net/url_request/url_request_context_getter.h" | 18 #include "net/url_request/url_request_context_getter.h" |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 } | 50 } |
50 | 51 |
51 scoped_ptr<CloudPrintRequest> CloudPrintRequest::CreatePost( | 52 scoped_ptr<CloudPrintRequest> CloudPrintRequest::CreatePost( |
52 const GURL& url, | 53 const GURL& url, |
53 const std::string& content, | 54 const std::string& content, |
54 const std::string& mimetype, | 55 const std::string& mimetype, |
55 Delegate* delegate) { | 56 Delegate* delegate) { |
56 scoped_ptr<CloudPrintRequest> request( | 57 scoped_ptr<CloudPrintRequest> request( |
57 new CloudPrintRequest(url, URLFetcher::POST, delegate)); | 58 new CloudPrintRequest(url, URLFetcher::POST, delegate)); |
58 request->fetcher_->SetUploadData(mimetype, content); | 59 request->fetcher_->SetUploadData(mimetype, content); |
59 return request.Pass(); | 60 return std::move(request); |
60 } | 61 } |
61 | 62 |
62 void CloudPrintRequest::Run( | 63 void CloudPrintRequest::Run( |
63 const std::string& access_token, | 64 const std::string& access_token, |
64 scoped_refptr<net::URLRequestContextGetter> context_getter) { | 65 scoped_refptr<net::URLRequestContextGetter> context_getter) { |
65 if (!access_token.empty()) | 66 if (!access_token.empty()) |
66 fetcher_->AddExtraRequestHeader(base::StringPrintf( | 67 fetcher_->AddExtraRequestHeader(base::StringPrintf( |
67 "Authorization: Bearer \"%s\"", access_token.c_str())); | 68 "Authorization: Bearer \"%s\"", access_token.c_str())); |
68 | 69 |
69 fetcher_->SetRequestContext(context_getter.get()); | 70 fetcher_->SetRequestContext(context_getter.get()); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 // TODO(maksymb): Add Privet |server_http_code| and |server_api| support in | 111 // TODO(maksymb): Add Privet |server_http_code| and |server_api| support in |
111 // case of server errors. | 112 // case of server errors. |
112 NOTIMPLEMENTED() << "HTTP code: " << http_code; | 113 NOTIMPLEMENTED() << "HTTP code: " << http_code; |
113 delegate_->OnFetchError("dummy", -1, http_code); // After this object can | 114 delegate_->OnFetchError("dummy", -1, http_code); // After this object can |
114 // be deleted. | 115 // be deleted. |
115 // Do *NOT* access members | 116 // Do *NOT* access members |
116 // after this call. | 117 // after this call. |
117 } | 118 } |
118 } | 119 } |
119 | 120 |
OLD | NEW |