OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "sync/internal_api/public/attachments/attachment_uploader_impl.h" | 5 #include "sync/internal_api/public/attachments/attachment_uploader_impl.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
| 8 #include <utility> |
8 #include <vector> | 9 #include <vector> |
9 | 10 |
10 #include "base/bind.h" | 11 #include "base/bind.h" |
11 #include "base/callback.h" | 12 #include "base/callback.h" |
12 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
13 #include "base/memory/ref_counted_memory.h" | 14 #include "base/memory/ref_counted_memory.h" |
14 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
15 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
16 #include "base/strings/string_number_conversions.h" | 17 #include "base/strings/string_number_conversions.h" |
17 #include "base/strings/stringprintf.h" | 18 #include "base/strings/stringprintf.h" |
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 scoped_ptr<HttpResponse> RequestHandler::HandleRequest( | 391 scoped_ptr<HttpResponse> RequestHandler::HandleRequest( |
391 const HttpRequest& request) { | 392 const HttpRequest& request) { |
392 DCHECK(CalledOnValidThread()); | 393 DCHECK(CalledOnValidThread()); |
393 test_task_runner_->PostTask( | 394 test_task_runner_->PostTask( |
394 FROM_HERE, | 395 FROM_HERE, |
395 base::Bind( | 396 base::Bind( |
396 &AttachmentUploaderImplTest::OnRequestReceived, test_, request)); | 397 &AttachmentUploaderImplTest::OnRequestReceived, test_, request)); |
397 scoped_ptr<BasicHttpResponse> response(new BasicHttpResponse); | 398 scoped_ptr<BasicHttpResponse> response(new BasicHttpResponse); |
398 response->set_code(GetStatusCode()); | 399 response->set_code(GetStatusCode()); |
399 response->set_content_type("text/plain"); | 400 response->set_content_type("text/plain"); |
400 return response.Pass(); | 401 return std::move(response); |
401 } | 402 } |
402 | 403 |
403 void RequestHandler::SetStatusCode(const net::HttpStatusCode& status_code) { | 404 void RequestHandler::SetStatusCode(const net::HttpStatusCode& status_code) { |
404 base::AutoLock lock(mutex_); | 405 base::AutoLock lock(mutex_); |
405 status_code_ = status_code; | 406 status_code_ = status_code; |
406 } | 407 } |
407 | 408 |
408 net::HttpStatusCode RequestHandler::GetStatusCode() const { | 409 net::HttpStatusCode RequestHandler::GetStatusCode() const { |
409 base::AutoLock lock(mutex_); | 410 base::AutoLock lock(mutex_); |
410 return status_code_; | 411 return status_code_; |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 scoped_refptr<base::RefCountedString> hello_world(new base::RefCountedString); | 674 scoped_refptr<base::RefCountedString> hello_world(new base::RefCountedString); |
674 hello_world->data() = "hello world"; | 675 hello_world->data() = "hello world"; |
675 EXPECT_EQ("yZRlqg==", AttachmentUploaderImpl::FormatCrc32cHash( | 676 EXPECT_EQ("yZRlqg==", AttachmentUploaderImpl::FormatCrc32cHash( |
676 ComputeCrc32c(hello_world))); | 677 ComputeCrc32c(hello_world))); |
677 } | 678 } |
678 | 679 |
679 // TODO(maniscalco): Add test case for when we are uploading an attachment that | 680 // TODO(maniscalco): Add test case for when we are uploading an attachment that |
680 // already exists. 409 Conflict? (bug 379825) | 681 // already exists. 409 Conflict? (bug 379825) |
681 | 682 |
682 } // namespace syncer | 683 } // namespace syncer |
OLD | NEW |