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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 return request.Pass(); | 57 return request.Pass(); |
58 } | 58 } |
59 | 59 |
60 void CloudPrintRequest::Run( | 60 void CloudPrintRequest::Run( |
61 const std::string& access_token, | 61 const std::string& access_token, |
62 scoped_refptr<net::URLRequestContextGetter> context_getter) { | 62 scoped_refptr<net::URLRequestContextGetter> context_getter) { |
63 if (!access_token.empty()) | 63 if (!access_token.empty()) |
64 fetcher_->AddExtraRequestHeader(base::StringPrintf( | 64 fetcher_->AddExtraRequestHeader(base::StringPrintf( |
65 "Authorization: Bearer \"%s\"", access_token.c_str())); | 65 "Authorization: Bearer \"%s\"", access_token.c_str())); |
66 | 66 |
67 fetcher_->SetRequestContext(context_getter); | 67 fetcher_->SetRequestContext(context_getter.get()); |
68 fetcher_->Start(); | 68 fetcher_->Start(); |
69 | 69 |
70 MessageLoop::current()->PostDelayedTask( | 70 MessageLoop::current()->PostDelayedTask( |
71 FROM_HERE, | 71 FROM_HERE, |
72 base::Bind(&CloudPrintRequest::OnRequestTimeout, AsWeakPtr()), | 72 base::Bind(&CloudPrintRequest::OnRequestTimeout, AsWeakPtr()), |
73 base::TimeDelta::FromSeconds(kDefaultTimeout)); | 73 base::TimeDelta::FromSeconds(kDefaultTimeout)); |
74 } | 74 } |
75 | 75 |
76 void CloudPrintRequest::AddHeader(const std::string& header) { | 76 void CloudPrintRequest::AddHeader(const std::string& header) { |
77 fetcher_->AddExtraRequestHeader(header); | 77 fetcher_->AddExtraRequestHeader(header); |
(...skipping 30 matching lines...) Expand all Loading... |
108 // TODO(maksymb): Add Privet |server_http_code| and |server_api| support in | 108 // TODO(maksymb): Add Privet |server_http_code| and |server_api| support in |
109 // case of server errors. | 109 // case of server errors. |
110 NOTIMPLEMENTED() << "HTTP code: " << http_code; | 110 NOTIMPLEMENTED() << "HTTP code: " << http_code; |
111 delegate_->OnFetchError("dummy", -1, http_code); // After this object can | 111 delegate_->OnFetchError("dummy", -1, http_code); // After this object can |
112 // be deleted. | 112 // be deleted. |
113 // Do *NOT* access members | 113 // Do *NOT* access members |
114 // after this call. | 114 // after this call. |
115 } | 115 } |
116 } | 116 } |
117 | 117 |
OLD | NEW |