OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "build/build_config.h" | 6 #include "build/build_config.h" |
7 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 7 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
8 #include "chrome/browser/bookmarks/enhanced_bookmarks_features.h" | 8 #include "chrome/browser/bookmarks/enhanced_bookmarks_features.h" |
9 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h" | 9 #include "chrome/browser/dom_distiller/dom_distiller_service_factory.h" |
10 #include "chrome/browser/history/history_service.h" | 10 #include "chrome/browser/history/history_service.h" |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
548 return base::WeakPtr<syncer::SyncableService>(); | 548 return base::WeakPtr<syncer::SyncableService>(); |
549 } | 549 } |
550 } | 550 } |
551 | 551 |
552 class TokenServiceProvider | 552 class TokenServiceProvider |
553 : public OAuth2TokenServiceRequest::TokenServiceProvider { | 553 : public OAuth2TokenServiceRequest::TokenServiceProvider { |
554 public: | 554 public: |
555 TokenServiceProvider( | 555 TokenServiceProvider( |
556 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 556 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
557 OAuth2TokenService* token_service); | 557 OAuth2TokenService* token_service); |
558 virtual ~TokenServiceProvider(); | |
559 | 558 |
560 // OAuth2TokenServiceRequest::TokenServiceProvider implementation. | 559 // OAuth2TokenServiceRequest::TokenServiceProvider implementation. |
561 virtual scoped_refptr<base::SingleThreadTaskRunner> | 560 virtual scoped_refptr<base::SingleThreadTaskRunner> |
562 GetTokenServiceTaskRunner() OVERRIDE; | 561 GetTokenServiceTaskRunner() OVERRIDE; |
563 virtual OAuth2TokenService* GetTokenService() OVERRIDE; | 562 virtual OAuth2TokenService* GetTokenService() OVERRIDE; |
564 | 563 |
565 private: | 564 private: |
| 565 virtual ~TokenServiceProvider(); |
| 566 |
566 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 567 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
567 OAuth2TokenService* token_service_; | 568 OAuth2TokenService* token_service_; |
568 }; | 569 }; |
569 | 570 |
570 TokenServiceProvider::TokenServiceProvider( | 571 TokenServiceProvider::TokenServiceProvider( |
571 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, | 572 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, |
572 OAuth2TokenService* token_service) | 573 OAuth2TokenService* token_service) |
573 : task_runner_(task_runner), token_service_(token_service) { | 574 : task_runner_(task_runner), token_service_(token_service) { |
574 } | 575 } |
575 | 576 |
(...skipping 18 matching lines...) Expand all Loading... |
594 new syncer::FakeAttachmentStore( | 595 new syncer::FakeAttachmentStore( |
595 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE))); | 596 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::FILE))); |
596 | 597 |
597 scoped_ptr<syncer::AttachmentUploader> attachment_uploader; | 598 scoped_ptr<syncer::AttachmentUploader> attachment_uploader; |
598 scoped_ptr<syncer::AttachmentDownloader> attachment_downloader; | 599 scoped_ptr<syncer::AttachmentDownloader> attachment_downloader; |
599 // Only construct an AttachmentUploader and AttachmentDownload if we have sync | 600 // Only construct an AttachmentUploader and AttachmentDownload if we have sync |
600 // credentials. We may not have sync credentials because there may not be a | 601 // credentials. We may not have sync credentials because there may not be a |
601 // signed in sync user (e.g. sync is running in "backup" mode). | 602 // signed in sync user (e.g. sync is running in "backup" mode). |
602 if (!user_share.sync_credentials.email.empty() && | 603 if (!user_share.sync_credentials.email.empty() && |
603 !user_share.sync_credentials.scope_set.empty()) { | 604 !user_share.sync_credentials.scope_set.empty()) { |
604 scoped_ptr<OAuth2TokenServiceRequest::TokenServiceProvider> | 605 scoped_refptr<OAuth2TokenServiceRequest::TokenServiceProvider> |
605 token_service_provider(new TokenServiceProvider( | 606 token_service_provider(new TokenServiceProvider( |
606 content::BrowserThread::GetMessageLoopProxyForThread( | 607 content::BrowserThread::GetMessageLoopProxyForThread( |
607 content::BrowserThread::UI), | 608 content::BrowserThread::UI), |
608 token_service_)); | 609 token_service_)); |
609 // TODO(maniscalco): Use shared (one per profile) thread-safe instances of | 610 // TODO(maniscalco): Use shared (one per profile) thread-safe instances of |
610 // AttachmentUploader and AttachmentDownloader instead of creating a new one | 611 // AttachmentUploader and AttachmentDownloader instead of creating a new one |
611 // per AttachmentService (bug 369536). | 612 // per AttachmentService (bug 369536). |
612 attachment_uploader.reset(new syncer::AttachmentUploaderImpl( | 613 attachment_uploader.reset(new syncer::AttachmentUploaderImpl( |
613 sync_service_url_, | 614 sync_service_url_, |
614 url_request_context_getter_, | 615 url_request_context_getter_, |
615 user_share.sync_credentials.email, | 616 user_share.sync_credentials.email, |
616 user_share.sync_credentials.scope_set, | 617 user_share.sync_credentials.scope_set, |
617 token_service_provider.Pass())); | 618 token_service_provider)); |
618 | 619 |
619 token_service_provider.reset(new TokenServiceProvider( | 620 token_service_provider = new TokenServiceProvider( |
620 content::BrowserThread::GetMessageLoopProxyForThread( | 621 content::BrowserThread::GetMessageLoopProxyForThread( |
621 content::BrowserThread::UI), | 622 content::BrowserThread::UI), |
622 token_service_)); | 623 token_service_); |
623 attachment_downloader = syncer::AttachmentDownloader::Create( | 624 attachment_downloader = syncer::AttachmentDownloader::Create( |
624 sync_service_url_, | 625 sync_service_url_, |
625 url_request_context_getter_, | 626 url_request_context_getter_, |
626 user_share.sync_credentials.email, | 627 user_share.sync_credentials.email, |
627 user_share.sync_credentials.scope_set, | 628 user_share.sync_credentials.scope_set, |
628 token_service_provider.Pass()); | 629 token_service_provider); |
629 } | 630 } |
630 | 631 |
631 scoped_ptr<syncer::AttachmentService> attachment_service( | 632 scoped_ptr<syncer::AttachmentService> attachment_service( |
632 new syncer::AttachmentServiceImpl(attachment_store.Pass(), | 633 new syncer::AttachmentServiceImpl(attachment_store.Pass(), |
633 attachment_uploader.Pass(), | 634 attachment_uploader.Pass(), |
634 attachment_downloader.Pass(), | 635 attachment_downloader.Pass(), |
635 delegate)); | 636 delegate)); |
636 | 637 |
637 return attachment_service.Pass(); | 638 return attachment_service.Pass(); |
638 } | 639 } |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 new TypedUrlModelAssociator(profile_sync_service, | 673 new TypedUrlModelAssociator(profile_sync_service, |
673 history_backend, | 674 history_backend, |
674 error_handler); | 675 error_handler); |
675 TypedUrlChangeProcessor* change_processor = | 676 TypedUrlChangeProcessor* change_processor = |
676 new TypedUrlChangeProcessor(profile_, | 677 new TypedUrlChangeProcessor(profile_, |
677 model_associator, | 678 model_associator, |
678 history_backend, | 679 history_backend, |
679 error_handler); | 680 error_handler); |
680 return SyncComponents(model_associator, change_processor); | 681 return SyncComponents(model_associator, change_processor); |
681 } | 682 } |
OLD | NEW |