Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: chrome/browser/drive/fake_drive_service.cc

Issue 21030009: Make element removal methods in DictionaryValue and ListValue take scoped_ptr's as outparams. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: sync Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/fake_drive_service.h" 5 #include "chrome/browser/drive/fake_drive_service.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/file_util.h" 9 #include "base/file_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 176
177 FakeDriveService::~FakeDriveService() { 177 FakeDriveService::~FakeDriveService() {
178 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 178 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
179 } 179 }
180 180
181 bool FakeDriveService::LoadResourceListForWapi( 181 bool FakeDriveService::LoadResourceListForWapi(
182 const std::string& relative_path) { 182 const std::string& relative_path) {
183 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 183 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
184 scoped_ptr<Value> raw_value = test_util::LoadJSONFile(relative_path); 184 scoped_ptr<Value> raw_value = test_util::LoadJSONFile(relative_path);
185 base::DictionaryValue* as_dict = NULL; 185 base::DictionaryValue* as_dict = NULL;
186 base::Value* feed = NULL; 186 scoped_ptr<base::Value> feed;
187 base::DictionaryValue* feed_as_dict = NULL; 187 base::DictionaryValue* feed_as_dict = NULL;
188 188
189 // Extract the "feed" from the raw value and take the ownership. 189 // Extract the "feed" from the raw value and take the ownership.
190 // Note that Remove() transfers the ownership to |feed|. 190 // Note that Remove() transfers the ownership to |feed|.
191 if (raw_value->GetAsDictionary(&as_dict) && 191 if (raw_value->GetAsDictionary(&as_dict) &&
192 as_dict->Remove("feed", &feed) && 192 as_dict->Remove("feed", &feed) &&
193 feed->GetAsDictionary(&feed_as_dict)) { 193 feed->GetAsDictionary(&feed_as_dict)) {
194 ignore_result(feed.release());
194 resource_list_value_.reset(feed_as_dict); 195 resource_list_value_.reset(feed_as_dict);
195 196
196 // Go through entries and convert test$data from a string to a binary blob. 197 // Go through entries and convert test$data from a string to a binary blob.
197 base::ListValue* entries = NULL; 198 base::ListValue* entries = NULL;
198 if (feed_as_dict->GetList("entry", &entries)) { 199 if (feed_as_dict->GetList("entry", &entries)) {
199 for (size_t i = 0; i < entries->GetSize(); ++i) { 200 for (size_t i = 0; i < entries->GetSize(); ++i) {
200 base::DictionaryValue* entry = NULL; 201 base::DictionaryValue* entry = NULL;
201 std::string content_data; 202 std::string content_data;
202 if (entries->GetDictionary(i, &entry) && 203 if (entries->GetDictionary(i, &entry) &&
203 entry->GetString("test$data", &content_data)) { 204 entry->GetString("test$data", &content_data)) {
204 entry->Set("test$data", base::BinaryValue::CreateWithCopiedBuffer( 205 entry->Set("test$data",
205 content_data.c_str(), content_data.size())); 206 base::BinaryValue::CreateWithCopiedBuffer(
207 content_data.c_str(), content_data.size()));
206 } 208 }
207 } 209 }
208 } 210 }
209 } 211 }
210 212
211 return resource_list_value_; 213 return resource_list_value_;
212 } 214 }
213 215
214 bool FakeDriveService::LoadAccountMetadataForWapi( 216 bool FakeDriveService::LoadAccountMetadataForWapi(
215 const std::string& relative_path) { 217 const std::string& relative_path) {
(...skipping 1330 matching lines...) Expand 10 before | Expand all | Expand 10 after
1546 FROM_HERE, 1548 FROM_HERE,
1547 base::Bind(callback, HTTP_SUCCESS, base::Passed(&resource_list))); 1549 base::Bind(callback, HTTP_SUCCESS, base::Passed(&resource_list)));
1548 } 1550 }
1549 1551
1550 GURL FakeDriveService::GetNewUploadSessionUrl() { 1552 GURL FakeDriveService::GetNewUploadSessionUrl() {
1551 return GURL("https://upload_session_url/" + 1553 return GURL("https://upload_session_url/" +
1552 base::Int64ToString(next_upload_sequence_number_++)); 1554 base::Int64ToString(next_upload_sequence_number_++));
1553 } 1555 }
1554 1556
1555 } // namespace drive 1557 } // namespace drive
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698