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 "components/enhanced_bookmarks/bookmark_server_service.h" | 5 #include "components/enhanced_bookmarks/bookmark_server_service.h" |
6 | 6 |
7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
8 #include "components/enhanced_bookmarks/enhanced_bookmark_model.h" | 8 #include "components/enhanced_bookmarks/enhanced_bookmark_model.h" |
9 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 9 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
10 #include "components/signin/core/browser/signin_manager_base.h" | 10 #include "components/signin/core/browser/signin_manager_base.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 observers_.AddObserver(observer); | 41 observers_.AddObserver(observer); |
42 } | 42 } |
43 | 43 |
44 void BookmarkServerService::RemoveObserver( | 44 void BookmarkServerService::RemoveObserver( |
45 BookmarkServerServiceObserver* observer) { | 45 BookmarkServerServiceObserver* observer) { |
46 observers_.RemoveObserver(observer); | 46 observers_.RemoveObserver(observer); |
47 } | 47 } |
48 | 48 |
49 const BookmarkNode* BookmarkServerService::BookmarkForRemoteId( | 49 const BookmarkNode* BookmarkServerService::BookmarkForRemoteId( |
50 const std::string& remote_id) const { | 50 const std::string& remote_id) const { |
51 std::map<std::string, const BookmarkNode*>::const_iterator it = | 51 return model_->BookmarkForRemoteId(remote_id); |
52 starsid_to_bookmark_.find(remote_id); | |
53 if (it == starsid_to_bookmark_.end()) | |
54 return NULL; | |
55 return it->second; | |
56 } | 52 } |
57 | 53 |
58 const std::string BookmarkServerService::RemoteIDForBookmark( | 54 const std::string BookmarkServerService::RemoteIDForBookmark( |
59 const BookmarkNode* bookmark) const { | 55 const BookmarkNode* bookmark) const { |
60 return model_->GetRemoteId(bookmark); | 56 return model_->GetRemoteId(bookmark); |
61 } | 57 } |
62 | 58 |
63 void BookmarkServerService::Notify() { | 59 void BookmarkServerService::Notify() { |
64 FOR_EACH_OBSERVER(BookmarkServerServiceObserver, observers_, OnChange(this)); | 60 FOR_EACH_OBSERVER(BookmarkServerServiceObserver, observers_, OnChange(this)); |
65 } | 61 } |
(...skipping 18 matching lines...) Expand all Loading... |
84 token_request_ = token_service_->StartRequest(username, scopes, this); | 80 token_request_ = token_service_->StartRequest(username, scopes, this); |
85 } | 81 } |
86 | 82 |
87 // | 83 // |
88 // OAuth2AccessTokenConsumer methods. | 84 // OAuth2AccessTokenConsumer methods. |
89 // | 85 // |
90 void BookmarkServerService::OnGetTokenSuccess( | 86 void BookmarkServerService::OnGetTokenSuccess( |
91 const OAuth2TokenService::Request* request, | 87 const OAuth2TokenService::Request* request, |
92 const std::string& access_token, | 88 const std::string& access_token, |
93 const base::Time& expiration_time) { | 89 const base::Time& expiration_time) { |
94 url_fetcher_.reset(CreateFetcher()); | 90 url_fetcher_ = CreateFetcher(); |
| 91 |
95 // Free the token request. | 92 // Free the token request. |
96 token_request_.reset(); | 93 token_request_.reset(); |
97 | 94 |
98 if (!url_fetcher_) { | 95 if (!url_fetcher_) { |
99 CleanAfterFailure(); | 96 CleanAfterFailure(); |
100 Notify(); | 97 Notify(); |
101 return; | 98 return; |
102 } | 99 } |
103 url_fetcher_->SetRequestContext(request_context_getter_.get()); | 100 url_fetcher_->SetRequestContext(request_context_getter_.get()); |
104 | 101 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 void BookmarkServerService::EnhancedBookmarkModelShuttingDown() { | 143 void BookmarkServerService::EnhancedBookmarkModelShuttingDown() { |
147 NOTREACHED(); | 144 NOTREACHED(); |
148 } | 145 } |
149 | 146 |
150 SigninManagerBase* BookmarkServerService::GetSigninManager() { | 147 SigninManagerBase* BookmarkServerService::GetSigninManager() { |
151 DCHECK(signin_manager_); | 148 DCHECK(signin_manager_); |
152 return signin_manager_; | 149 return signin_manager_; |
153 } | 150 } |
154 | 151 |
155 } // namespace enhanced_bookmarks | 152 } // namespace enhanced_bookmarks |
OLD | NEW |