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 "chrome/browser/drive/gdata_wapi_service.h" | 5 #include "chrome/browser/drive/gdata_wapi_service.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
124 app_list = AppList::CreateFromAccountMetadata(*account_metadata); | 124 app_list = AppList::CreateFromAccountMetadata(*account_metadata); |
125 } | 125 } |
126 | 126 |
127 callback.Run(error, app_list.Pass()); | 127 callback.Run(error, app_list.Pass()); |
128 } | 128 } |
129 | 129 |
130 } // namespace | 130 } // namespace |
131 | 131 |
132 GDataWapiService::GDataWapiService( | 132 GDataWapiService::GDataWapiService( |
133 OAuth2TokenService* oauth2_token_service, | 133 OAuth2TokenService* oauth2_token_service, |
134 const std::string& account_id, | |
134 net::URLRequestContextGetter* url_request_context_getter, | 135 net::URLRequestContextGetter* url_request_context_getter, |
135 base::TaskRunner* blocking_task_runner, | 136 base::TaskRunner* blocking_task_runner, |
136 const GURL& base_url, | 137 const GURL& base_url, |
137 const GURL& base_download_url, | 138 const GURL& base_download_url, |
138 const std::string& custom_user_agent) | 139 const std::string& custom_user_agent) |
139 : oauth2_token_service_(oauth2_token_service), | 140 : oauth2_token_service_(oauth2_token_service), |
141 account_id_(account_id), | |
140 url_request_context_getter_(url_request_context_getter), | 142 url_request_context_getter_(url_request_context_getter), |
141 blocking_task_runner_(blocking_task_runner), | 143 blocking_task_runner_(blocking_task_runner), |
142 url_generator_(base_url, base_download_url), | 144 url_generator_(base_url, base_download_url), |
143 custom_user_agent_(custom_user_agent) { | 145 custom_user_agent_(custom_user_agent) { |
144 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 146 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
145 } | 147 } |
146 | 148 |
147 GDataWapiService::~GDataWapiService() { | 149 GDataWapiService::~GDataWapiService() { |
148 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 150 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
149 if (sender_.get()) | 151 if (sender_.get()) |
150 sender_->auth_service()->RemoveObserver(this); | 152 sender_->auth_service()->RemoveObserver(this); |
151 } | 153 } |
152 | 154 |
153 void GDataWapiService::Initialize() { | 155 void GDataWapiService::Initialize() { |
154 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 156 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
155 | 157 |
156 std::vector<std::string> scopes; | 158 std::vector<std::string> scopes; |
157 scopes.push_back(util::kDocsListScope); | 159 scopes.push_back(util::kDocsListScope); |
158 scopes.push_back(kSpreadsheetsScope); | 160 scopes.push_back(kSpreadsheetsScope); |
159 scopes.push_back(kUserContentScope); | 161 scopes.push_back(kUserContentScope); |
160 // Drive App scope is required for even WAPI v3 apps access. | 162 // Drive App scope is required for even WAPI v3 apps access. |
161 scopes.push_back(util::kDriveAppsScope); | 163 scopes.push_back(util::kDriveAppsScope); |
162 sender_.reset(new RequestSender( | 164 sender_.reset(new RequestSender( |
163 new AuthService( | 165 new AuthService(oauth2_token_service_, account_id_, |
Andrew T Wilson (Slow)
2013/08/30 10:47:00
Wrong wrap? http://google-styleguide.googlecode.co
fgorski
2013/08/30 20:10:16
Done.
| |
164 oauth2_token_service_, url_request_context_getter_, scopes), | 166 url_request_context_getter_, scopes), |
165 url_request_context_getter_, | 167 url_request_context_getter_, |
166 blocking_task_runner_.get(), | 168 blocking_task_runner_.get(), |
167 custom_user_agent_)); | 169 custom_user_agent_)); |
168 | 170 |
169 sender_->auth_service()->AddObserver(this); | 171 sender_->auth_service()->AddObserver(this); |
170 } | 172 } |
171 | 173 |
172 void GDataWapiService::AddObserver(DriveServiceObserver* observer) { | 174 void GDataWapiService::AddObserver(DriveServiceObserver* observer) { |
173 observers_.AddObserver(observer); | 175 observers_.AddObserver(observer); |
174 } | 176 } |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
666 if (CanSendRequest()) { | 668 if (CanSendRequest()) { |
667 FOR_EACH_OBSERVER( | 669 FOR_EACH_OBSERVER( |
668 DriveServiceObserver, observers_, OnReadyToSendRequests()); | 670 DriveServiceObserver, observers_, OnReadyToSendRequests()); |
669 } else if (!HasRefreshToken()) { | 671 } else if (!HasRefreshToken()) { |
670 FOR_EACH_OBSERVER( | 672 FOR_EACH_OBSERVER( |
671 DriveServiceObserver, observers_, OnRefreshTokenInvalid()); | 673 DriveServiceObserver, observers_, OnRefreshTokenInvalid()); |
672 } | 674 } |
673 } | 675 } |
674 | 676 |
675 } // namespace drive | 677 } // namespace drive |
OLD | NEW |