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_downloader_impl.h" | 5 #include "sync/internal_api/public/attachments/attachment_downloader_impl.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
| 12 #include "base/location.h" |
12 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
13 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
14 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
| 16 #include "base/single_thread_task_runner.h" |
15 #include "base/test/histogram_tester.h" | 17 #include "base/test/histogram_tester.h" |
16 #include "base/threading/thread_task_runner_handle.h" | 18 #include "base/threading/thread_task_runner_handle.h" |
17 #include "google_apis/gaia/fake_oauth2_token_service.h" | 19 #include "google_apis/gaia/fake_oauth2_token_service.h" |
18 #include "google_apis/gaia/gaia_constants.h" | 20 #include "google_apis/gaia/gaia_constants.h" |
19 #include "net/http/http_response_headers.h" | 21 #include "net/http/http_response_headers.h" |
20 #include "net/url_request/test_url_fetcher_factory.h" | 22 #include "net/url_request/test_url_fetcher_factory.h" |
21 #include "net/url_request/url_request_test_util.h" | 23 #include "net/url_request/url_request_test_util.h" |
22 #include "sync/api/attachments/attachment.h" | 24 #include "sync/api/attachments/attachment.h" |
23 #include "sync/internal_api/public/attachments/attachment_uploader_impl.h" | 25 #include "sync/internal_api/public/attachments/attachment_uploader_impl.h" |
24 #include "sync/internal_api/public/attachments/attachment_util.h" | 26 #include "sync/internal_api/public/attachments/attachment_util.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 | 72 |
71 void MockOAuth2TokenService::RespondToAccessTokenRequest( | 73 void MockOAuth2TokenService::RespondToAccessTokenRequest( |
72 GoogleServiceAuthError error) { | 74 GoogleServiceAuthError error) { |
73 EXPECT_TRUE(last_request_); | 75 EXPECT_TRUE(last_request_); |
74 std::string access_token; | 76 std::string access_token; |
75 base::Time expiration_time; | 77 base::Time expiration_time; |
76 if (error == GoogleServiceAuthError::AuthErrorNone()) { | 78 if (error == GoogleServiceAuthError::AuthErrorNone()) { |
77 access_token = kAccessToken; | 79 access_token = kAccessToken; |
78 expiration_time = base::Time::Max(); | 80 expiration_time = base::Time::Max(); |
79 } | 81 } |
80 base::MessageLoop::current()->PostTask( | 82 base::ThreadTaskRunnerHandle::Get()->PostTask( |
81 FROM_HERE, | 83 FROM_HERE, |
82 base::Bind(&OAuth2TokenService::RequestImpl::InformConsumer, | 84 base::Bind(&OAuth2TokenService::RequestImpl::InformConsumer, |
83 last_request_, | 85 last_request_, error, access_token, expiration_time)); |
84 error, | |
85 access_token, | |
86 expiration_time)); | |
87 } | 86 } |
88 | 87 |
89 void MockOAuth2TokenService::FetchOAuth2Token( | 88 void MockOAuth2TokenService::FetchOAuth2Token( |
90 RequestImpl* request, | 89 RequestImpl* request, |
91 const std::string& account_id, | 90 const std::string& account_id, |
92 net::URLRequestContextGetter* getter, | 91 net::URLRequestContextGetter* getter, |
93 const std::string& client_id, | 92 const std::string& client_id, |
94 const std::string& client_secret, | 93 const std::string& client_secret, |
95 const ScopeSet& scopes) { | 94 const ScopeSet& scopes) { |
96 // Only one request at a time is allowed. | 95 // Only one request at a time is allowed. |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 raw += "\n"; | 531 raw += "\n"; |
533 std::replace(raw.begin(), raw.end(), '\n', '\0'); | 532 std::replace(raw.begin(), raw.end(), '\n', '\0'); |
534 scoped_refptr<net::HttpResponseHeaders> headers( | 533 scoped_refptr<net::HttpResponseHeaders> headers( |
535 new net::HttpResponseHeaders(raw)); | 534 new net::HttpResponseHeaders(raw)); |
536 uint32_t extracted; | 535 uint32_t extracted; |
537 ASSERT_FALSE( | 536 ASSERT_FALSE( |
538 AttachmentDownloaderImpl::ExtractCrc32c(headers.get(), &extracted)); | 537 AttachmentDownloaderImpl::ExtractCrc32c(headers.get(), &extracted)); |
539 } | 538 } |
540 | 539 |
541 } // namespace syncer | 540 } // namespace syncer |
OLD | NEW |