summaryrefslogtreecommitdiffstats
path: root/google_apis
diff options
context:
space:
mode:
authorkinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-07 15:54:34 +0000
committerkinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-08-07 15:54:34 +0000
commitf992db079eab5fcedf9d196719264df71c1106a9 (patch)
treea86d5b0b07e0d71a85ea4cae6b7933b4766474fc /google_apis
parent56611cb43a4d4fc5eba3a07dec1c91321ecadd0c (diff)
downloadchromium_src-f992db079eab5fcedf9d196719264df71c1106a9.zip
chromium_src-f992db079eab5fcedf9d196719264df71c1106a9.tar.gz
chromium_src-f992db079eab5fcedf9d196719264df71c1106a9.tar.bz2
Random cleanup around google_apis/drive and c/b/drive.
BUG=none Review URL: https://codereview.chromium.org/443303003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@288058 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'google_apis')
-rw-r--r--google_apis/drive/auth_service.cc48
-rw-r--r--google_apis/drive/base_requests.cc7
-rw-r--r--google_apis/drive/drive_api_parser.cc9
-rw-r--r--google_apis/drive/drive_api_parser_unittest.cc1
-rw-r--r--google_apis/drive/gdata_wapi_parser_unittest.cc2
5 files changed, 24 insertions, 43 deletions
diff --git a/google_apis/drive/auth_service.cc b/google_apis/drive/auth_service.cc
index 51229f9..0ab8fdf 100644
--- a/google_apis/drive/auth_service.cc
+++ b/google_apis/drive/auth_service.cc
@@ -9,7 +9,7 @@
#include "base/bind.h"
#include "base/location.h"
-#include "base/message_loop/message_loop_proxy.h"
+#include "base/message_loop/message_loop.h"
#include "base/metrics/histogram.h"
#include "google_apis/drive/auth_service_observer.h"
#include "google_apis/gaia/google_service_auth_error.h"
@@ -27,6 +27,12 @@ const int kSuccessRatioHistogramNoConnection = 2;
const int kSuccessRatioHistogramTemporaryFailure = 3;
const int kSuccessRatioHistogramMaxValue = 4; // The max value is exclusive.
+void RecordAuthResultHistogram(int value) {
+ UMA_HISTOGRAM_ENUMERATION("GData.AuthSuccess",
+ value,
+ kSuccessRatioHistogramMaxValue);
+}
+
// OAuth2 authorization token retrieval request.
class AuthRequest : public OAuth2TokenService::Consumer {
public:
@@ -78,10 +84,7 @@ void AuthRequest::OnGetTokenSuccess(const OAuth2TokenService::Request* request,
const base::Time& expiration_time) {
DCHECK(thread_checker_.CalledOnValidThread());
- UMA_HISTOGRAM_ENUMERATION("GData.AuthSuccess",
- kSuccessRatioHistogramSuccess,
- kSuccessRatioHistogramMaxValue);
-
+ RecordAuthResultHistogram(kSuccessRatioHistogramSuccess);
callback_.Run(HTTP_SUCCESS, access_token);
delete this;
}
@@ -98,21 +101,14 @@ void AuthRequest::OnGetTokenFailure(const OAuth2TokenService::Request* request,
// it's likely that the device is off-line. We treat the error differently
// so that the file manager works while off-line.
if (error.state() == GoogleServiceAuthError::CONNECTION_FAILED) {
- UMA_HISTOGRAM_ENUMERATION("GData.AuthSuccess",
- kSuccessRatioHistogramNoConnection,
- kSuccessRatioHistogramMaxValue);
+ RecordAuthResultHistogram(kSuccessRatioHistogramNoConnection);
callback_.Run(GDATA_NO_CONNECTION, std::string());
} else if (error.state() == GoogleServiceAuthError::SERVICE_UNAVAILABLE) {
- // Temporary auth error.
- UMA_HISTOGRAM_ENUMERATION("GData.AuthSuccess",
- kSuccessRatioHistogramTemporaryFailure,
- kSuccessRatioHistogramMaxValue);
+ RecordAuthResultHistogram(kSuccessRatioHistogramTemporaryFailure);
callback_.Run(HTTP_FORBIDDEN, std::string());
} else {
// Permanent auth error.
- UMA_HISTOGRAM_ENUMERATION("GData.AuthSuccess",
- kSuccessRatioHistogramFailure,
- kSuccessRatioHistogramMaxValue);
+ RecordAuthResultHistogram(kSuccessRatioHistogramFailure);
callback_.Run(HTTP_UNAUTHORIZED, std::string());
}
delete this;
@@ -144,13 +140,11 @@ AuthService::~AuthService() {
void AuthService::StartAuthentication(const AuthStatusCallback& callback) {
DCHECK(thread_checker_.CalledOnValidThread());
- scoped_refptr<base::MessageLoopProxy> relay_proxy(
- base::MessageLoopProxy::current());
if (HasAccessToken()) {
// We already have access token. Give it back to the caller asynchronously.
- relay_proxy->PostTask(FROM_HERE,
- base::Bind(callback, HTTP_SUCCESS, access_token_));
+ base::MessageLoop::current()->PostTask(
+ FROM_HERE, base::Bind(callback, HTTP_SUCCESS, access_token_));
} else if (HasRefreshToken()) {
// We have refresh token, let's get an access token.
new AuthRequest(oauth2_token_service_,
@@ -161,8 +155,8 @@ void AuthService::StartAuthentication(const AuthStatusCallback& callback) {
callback),
scopes_);
} else {
- relay_proxy->PostTask(FROM_HERE,
- base::Bind(callback, GDATA_NOT_READY, std::string()));
+ base::MessageLoop::current()->PostTask(
+ FROM_HERE, base::Bind(callback, GDATA_NOT_READY, std::string()));
}
}
@@ -183,11 +177,7 @@ void AuthService::ClearAccessToken() {
}
void AuthService::ClearRefreshToken() {
- has_refresh_token_ = false;
-
- FOR_EACH_OBSERVER(AuthServiceObserver,
- observers_,
- OnOAuth2RefreshTokenChanged());
+ OnHandleRefreshToken(false);
}
void AuthService::OnAuthCompleted(const AuthStatusCallback& callback,
@@ -221,11 +211,13 @@ void AuthService::RemoveObserver(AuthServiceObserver* observer) {
}
void AuthService::OnRefreshTokenAvailable(const std::string& account_id) {
- OnHandleRefreshToken(true);
+ if (account_id == account_id_)
+ OnHandleRefreshToken(true);
}
void AuthService::OnRefreshTokenRevoked(const std::string& account_id) {
- OnHandleRefreshToken(false);
+ if (account_id == account_id_)
+ OnHandleRefreshToken(false);
}
void AuthService::OnHandleRefreshToken(bool has_refresh_token) {
diff --git a/google_apis/drive/base_requests.cc b/google_apis/drive/base_requests.cc
index 0b2f5e0..fe058fe 100644
--- a/google_apis/drive/base_requests.cc
+++ b/google_apis/drive/base_requests.cc
@@ -59,8 +59,7 @@ void ParseJsonOnBlockingPool(
// Returns response headers as a string. Returns a warning message if
// |url_fetcher| does not contain a valid response. Used only for debugging.
-std::string GetResponseHeadersAsString(
- const URLFetcher* url_fetcher) {
+std::string GetResponseHeadersAsString(const URLFetcher* url_fetcher) {
// net::HttpResponseHeaders::raw_headers(), as the name implies, stores
// all headers in their raw format, i.e each header is null-terminated.
// So logging raw_headers() only shows the first header, which is probably
@@ -190,6 +189,7 @@ void ResponseWriter::DidWrite(scoped_refptr<net::IOBuffer> buffer,
UrlFetchRequestBase::UrlFetchRequestBase(RequestSender* sender)
: re_authenticate_count_(0),
+ response_writer_(NULL),
sender_(sender),
error_code_(GDATA_OTHER_ERROR),
weak_ptr_factory_(this) {
@@ -218,8 +218,7 @@ void UrlFetchRequestBase::Start(const std::string& access_token,
DVLOG(1) << "URL: " << url.spec();
URLFetcher::RequestType request_type = GetRequestType();
- url_fetcher_.reset(
- URLFetcher::Create(url, request_type, this));
+ url_fetcher_.reset(URLFetcher::Create(url, request_type, this));
url_fetcher_->SetRequestContext(sender_->url_request_context_getter());
// Always set flags to neither send nor save cookies.
url_fetcher_->SetLoadFlags(
diff --git a/google_apis/drive/drive_api_parser.cc b/google_apis/drive/drive_api_parser.cc
index 89c6a9e..998fb05 100644
--- a/google_apis/drive/drive_api_parser.cc
+++ b/google_apis/drive/drive_api_parser.cc
@@ -4,10 +4,7 @@
#include "google_apis/drive/drive_api_parser.h"
-#include <algorithm>
-
#include "base/basictypes.h"
-#include "base/files/file_path.h"
#include "base/json/json_value_converter.h"
#include "base/memory/scoped_ptr.h"
#include "base/strings/string_number_conversions.h"
@@ -16,10 +13,6 @@
#include "base/values.h"
#include "google_apis/drive/time_util.h"
-using base::Value;
-using base::DictionaryValue;
-using base::ListValue;
-
namespace google_apis {
namespace {
@@ -75,7 +68,7 @@ bool GetOpenWithLinksFromDictionaryValue(
return false;
result->reserve(dictionary_value->size());
- for (DictionaryValue::Iterator iter(*dictionary_value);
+ for (base::DictionaryValue::Iterator iter(*dictionary_value);
!iter.IsAtEnd(); iter.Advance()) {
std::string string_value;
if (!iter.value().GetAsString(&string_value))
diff --git a/google_apis/drive/drive_api_parser_unittest.cc b/google_apis/drive/drive_api_parser_unittest.cc
index 86fc482..c1d49b8 100644
--- a/google_apis/drive/drive_api_parser_unittest.cc
+++ b/google_apis/drive/drive_api_parser_unittest.cc
@@ -6,7 +6,6 @@
#include "base/time/time.h"
#include "base/values.h"
-#include "google_apis/drive/gdata_wapi_parser.h"
#include "google_apis/drive/test_util.h"
#include "google_apis/drive/time_util.h"
#include "testing/gtest/include/gtest/gtest.h"
diff --git a/google_apis/drive/gdata_wapi_parser_unittest.cc b/google_apis/drive/gdata_wapi_parser_unittest.cc
index 8f14d92..fd15a95 100644
--- a/google_apis/drive/gdata_wapi_parser_unittest.cc
+++ b/google_apis/drive/gdata_wapi_parser_unittest.cc
@@ -6,9 +6,7 @@
#include <string>
-#include "base/files/file_path.h"
#include "base/json/json_file_value_serializer.h"
-#include "base/logging.h"
#include "base/time/time.h"
#include "base/values.h"
#include "google_apis/drive/test_util.h"