Skip to content

Commit

Permalink
Remove ScopedVector from google_apis/.
Browse files Browse the repository at this point in the history
BUG=554289

Review-Url: https://codereview.chromium.org/2636703003
Cr-Commit-Position: refs/heads/master@{#443841}
  • Loading branch information
leon.han authored and Commit bot committed Jan 16, 2017
1 parent 35eb49f commit 6f34a0a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
15 changes: 8 additions & 7 deletions google_apis/drive/drive_api_requests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "base/callback.h"
#include "base/json/json_writer.h"
#include "base/location.h"
#include "base/memory/ptr_util.h"
#include "base/metrics/histogram_macros.h"
#include "base/metrics/sparse_histogram.h"
#include "base/sequenced_task_runner.h"
Expand Down Expand Up @@ -1226,7 +1227,7 @@ void BatchUploadRequest::AddRequest(BatchableDelegate* request) {
DCHECK(request);
DCHECK(GetChildEntry(request) == child_requests_.end());
DCHECK(!committed_);
child_requests_.push_back(new BatchUploadChildEntry(request));
child_requests_.push_back(base::MakeUnique<BatchUploadChildEntry>(request));
request->Prepare(base::Bind(&BatchUploadRequest::OnChildRequestPrepared,
weak_ptr_factory_.GetWeakPtr(), request));
}
Expand Down Expand Up @@ -1270,8 +1271,8 @@ void BatchUploadRequest::Cancel() {

// Obtains corresponding child entry of |request_id|. Returns NULL if the
// entry is not found.
ScopedVector<BatchUploadChildEntry>::iterator BatchUploadRequest::GetChildEntry(
RequestID request_id) {
std::vector<std::unique_ptr<BatchUploadChildEntry>>::iterator
BatchUploadRequest::GetChildEntry(RequestID request_id) {
for (auto it = child_requests_.begin(); it != child_requests_.end(); ++it) {
if ((*it)->request.get() == request_id)
return it;
Expand All @@ -1282,15 +1283,15 @@ ScopedVector<BatchUploadChildEntry>::iterator BatchUploadRequest::GetChildEntry(
void BatchUploadRequest::MayCompletePrepare() {
if (!committed_ || prepare_callback_.is_null())
return;
for (auto* child : child_requests_) {
for (const auto& child : child_requests_) {
if (!child->prepared)
return;
}

// Build multipart body here.
int64_t total_size = 0;
std::vector<ContentTypeAndData> parts;
for (auto* child : child_requests_) {
for (const auto& child : child_requests_) {
std::string type;
std::string data;
const bool result = child->request->GetContentData(&type, &data);
Expand Down Expand Up @@ -1409,15 +1410,15 @@ void BatchUploadRequest::ProcessURLFetchResults(const net::URLFetcher* source) {
}

void BatchUploadRequest::RunCallbackOnPrematureFailure(DriveApiErrorCode code) {
for (auto* child : child_requests_)
for (const auto& child : child_requests_)
child->request->NotifyError(code);
child_requests_.clear();
}

void BatchUploadRequest::OnURLFetchUploadProgress(const net::URLFetcher* source,
int64_t current,
int64_t total) {
for (auto* child : child_requests_) {
for (const auto& child : child_requests_) {
if (child->data_offset <= current &&
current <= child->data_offset + child->data_size) {
child->request->NotifyUploadProgress(source, current - child->data_offset,
Expand Down
5 changes: 2 additions & 3 deletions google_apis/drive/drive_api_requests.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include "base/callback_forward.h"
#include "base/location.h"
#include "base/macros.h"
#include "base/memory/scoped_vector.h"
#include "base/sequenced_task_runner.h"
#include "base/task_runner_util.h"
#include "base/time/time.h"
Expand Down Expand Up @@ -1227,7 +1226,7 @@ class BatchUploadRequest : public UrlFetchRequestBase {
typedef void* RequestID;
// Obtains corresponding child entry of |request_id|. Returns NULL if the
// entry is not found.
ScopedVector<BatchUploadChildEntry>::iterator GetChildEntry(
std::vector<std::unique_ptr<BatchUploadChildEntry>>::iterator GetChildEntry(
RequestID request_id);

// Called after child requests' |Prepare| method.
Expand All @@ -1241,7 +1240,7 @@ class BatchUploadRequest : public UrlFetchRequestBase {

RequestSender* const sender_;
const DriveApiUrlGenerator url_generator_;
ScopedVector<BatchUploadChildEntry> child_requests_;
std::vector<std::unique_ptr<BatchUploadChildEntry>> child_requests_;

PrepareCallback prepare_callback_;
bool committed_;
Expand Down
2 changes: 1 addition & 1 deletion google_apis/drive/test_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ std::string TestGetContentCallback::GetConcatenatedData() const {

void TestGetContentCallback::OnGetContent(google_apis::DriveApiErrorCode error,
std::unique_ptr<std::string> data) {
data_.push_back(data.release());
data_.push_back(std::move(data));
}

} // namespace test_util
Expand Down
9 changes: 5 additions & 4 deletions google_apis/drive/test_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include "base/bind.h"
#include "base/callback.h"
#include "base/macros.h"
#include "base/memory/scoped_vector.h"
#include "google_apis/drive/base_requests.h"
#include "google_apis/drive/drive_api_error_codes.h"
#include "google_apis/drive/task_util.h"
Expand Down Expand Up @@ -282,16 +281,18 @@ class TestGetContentCallback {
~TestGetContentCallback();

const GetContentCallback& callback() const { return callback_; }
const ScopedVector<std::string>& data() const { return data_; }
ScopedVector<std::string>* mutable_data() { return &data_; }
const std::vector<std::unique_ptr<std::string>>& data() const {
return data_;
}
std::vector<std::unique_ptr<std::string>>* mutable_data() { return &data_; }
std::string GetConcatenatedData() const;

private:
void OnGetContent(google_apis::DriveApiErrorCode error,
std::unique_ptr<std::string> data);

const GetContentCallback callback_;
ScopedVector<std::string> data_;
std::vector<std::unique_ptr<std::string>> data_;

DISALLOW_COPY_AND_ASSIGN(TestGetContentCallback);
};
Expand Down

0 comments on commit 6f34a0a

Please sign in to comment.