Skip to content

Commit

Permalink
Change most uses of Pickle to base::Pickle
Browse files Browse the repository at this point in the history
There should be no behavior change.

TBR=jschuh (IPC messages)

Review URL: https://codereview.chromium.org/1154283003

Cr-Commit-Position: refs/heads/master@{#332552}
  • Loading branch information
brettw authored and Commit bot committed Jun 3, 2015
1 parent 6f89d8f commit bd4d711
Show file tree
Hide file tree
Showing 190 changed files with 986 additions and 841 deletions.
8 changes: 4 additions & 4 deletions android_webview/native/aw_contents.cc
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ AwContents::GetOpaqueState(JNIEnv* env, jobject obj) {
if (!web_contents_->GetController().GetEntryCount())
return ScopedJavaLocalRef<jbyteArray>();

Pickle pickle;
base::Pickle pickle;
if (!WriteToPickle(*web_contents_, &pickle)) {
return ScopedJavaLocalRef<jbyteArray>();
} else {
Expand All @@ -863,9 +863,9 @@ jboolean AwContents::RestoreFromOpaqueState(
std::vector<uint8> state_vector;
base::android::JavaByteArrayToByteVector(env, state, &state_vector);

Pickle pickle(reinterpret_cast<const char*>(state_vector.data()),
state_vector.size());
PickleIterator iterator(pickle);
base::Pickle pickle(reinterpret_cast<const char*>(state_vector.data()),
state_vector.size());
base::PickleIterator iterator(pickle);

return RestoreFromPickle(&iterator, web_contents_.get());
}
Expand Down
12 changes: 6 additions & 6 deletions android_webview/native/state_serializer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const uint32 AW_STATE_VERSION = 20130814;
} // namespace

bool WriteToPickle(const content::WebContents& web_contents,
Pickle* pickle) {
base::Pickle* pickle) {
DCHECK(pickle);

if (!internal::WriteHeaderToPickle(pickle))
Expand Down Expand Up @@ -71,7 +71,7 @@ bool WriteToPickle(const content::WebContents& web_contents,
return true;
}

bool RestoreFromPickle(PickleIterator* iterator,
bool RestoreFromPickle(base::PickleIterator* iterator,
content::WebContents* web_contents) {
DCHECK(iterator);
DCHECK(web_contents);
Expand Down Expand Up @@ -136,11 +136,11 @@ bool RestoreFromPickle(PickleIterator* iterator,

namespace internal {

bool WriteHeaderToPickle(Pickle* pickle) {
bool WriteHeaderToPickle(base::Pickle* pickle) {
return pickle->WriteUInt32(AW_STATE_VERSION);
}

bool RestoreHeaderFromPickle(PickleIterator* iterator) {
bool RestoreHeaderFromPickle(base::PickleIterator* iterator) {
uint32 state_version = -1;
if (!iterator->ReadUInt32(&state_version))
return false;
Expand All @@ -152,7 +152,7 @@ bool RestoreHeaderFromPickle(PickleIterator* iterator) {
}

bool WriteNavigationEntryToPickle(const content::NavigationEntry& entry,
Pickle* pickle) {
base::Pickle* pickle) {
if (!pickle->WriteString(entry.GetURL().spec()))
return false;

Expand Down Expand Up @@ -194,7 +194,7 @@ bool WriteNavigationEntryToPickle(const content::NavigationEntry& entry,
return true;
}

bool RestoreNavigationEntryFromPickle(PickleIterator* iterator,
bool RestoreNavigationEntryFromPickle(base::PickleIterator* iterator,
content::NavigationEntry* entry) {
{
string url;
Expand Down
8 changes: 4 additions & 4 deletions android_webview/native/state_serializer_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ using std::string;
namespace android_webview {

TEST(AndroidWebViewStateSerializerTest, TestHeaderSerialization) {
Pickle pickle;
base::Pickle pickle;
bool result = internal::WriteHeaderToPickle(&pickle);
EXPECT_TRUE(result);

PickleIterator iterator(pickle);
base::PickleIterator iterator(pickle);
result = internal::RestoreHeaderFromPickle(&iterator);
EXPECT_TRUE(result);
}
Expand Down Expand Up @@ -68,12 +68,12 @@ TEST(AndroidWebViewStateSerializerTest, TestNavigationEntrySerialization) {
entry->SetTimestamp(timestamp);
entry->SetHttpStatusCode(http_status_code);

Pickle pickle;
base::Pickle pickle;
bool result = internal::WriteNavigationEntryToPickle(*entry, &pickle);
EXPECT_TRUE(result);

scoped_ptr<content::NavigationEntry> copy(content::NavigationEntry::Create());
PickleIterator iterator(pickle);
base::PickleIterator iterator(pickle);
result = internal::RestoreNavigationEntryFromPickle(&iterator, copy.get());
EXPECT_TRUE(result);

Expand Down
34 changes: 18 additions & 16 deletions chrome/browser/android/tab_state.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ using content::WebContents;

namespace {

bool WriteStateHeaderToPickle(bool off_the_record, int entry_count,
int current_entry_index, Pickle* pickle) {
bool WriteStateHeaderToPickle(bool off_the_record,
int entry_count,
int current_entry_index,
base::Pickle* pickle) {
return pickle->WriteBool(off_the_record) &&
pickle->WriteInt(entry_count) &&
pickle->WriteInt(current_entry_index);
Expand Down Expand Up @@ -66,10 +68,9 @@ bool WriteStateHeaderToPickle(bool off_the_record, int entry_count,
void UpgradeNavigationFromV0ToV2(
std::vector<sessions::SerializedNavigationEntry>* navigations,
int entry_count,
PickleIterator* iterator) {

base::PickleIterator* iterator) {
for (int i = 0; i < entry_count; ++i) {
Pickle v2_pickle;
base::Pickle v2_pickle;
std::string virtual_url_spec;
std::string str_referrer;
base::string16 title;
Expand Down Expand Up @@ -104,7 +105,7 @@ void UpgradeNavigationFromV0ToV2(
// search_terms
v2_pickle.WriteString16(base::string16());

PickleIterator tab_navigation_pickle_iterator(v2_pickle);
base::PickleIterator tab_navigation_pickle_iterator(v2_pickle);
sessions::SerializedNavigationEntry nav;
if (nav.ReadFromPickle(&tab_navigation_pickle_iterator)) {
navigations->push_back(nav);
Expand Down Expand Up @@ -152,9 +153,9 @@ void UpgradeNavigationFromV0ToV2(
void UpgradeNavigationFromV1ToV2(
std::vector<sessions::SerializedNavigationEntry>* navigations,
int entry_count,
PickleIterator* iterator) {
base::PickleIterator* iterator) {
for (int i = 0; i < entry_count; ++i) {
Pickle v2_pickle;
base::Pickle v2_pickle;

int index;
std::string virtual_url_spec;
Expand Down Expand Up @@ -203,7 +204,7 @@ void UpgradeNavigationFromV1ToV2(
// Force output of search_terms
v2_pickle.WriteString16(base::string16());

PickleIterator tab_navigation_pickle_iterator(v2_pickle);
base::PickleIterator tab_navigation_pickle_iterator(v2_pickle);
sessions::SerializedNavigationEntry nav;
if (nav.ReadFromPickle(&tab_navigation_pickle_iterator)) {
navigations->push_back(nav);
Expand All @@ -224,8 +225,8 @@ bool ExtractNavigationEntries(
int* current_entry_index,
std::vector<sessions::SerializedNavigationEntry>* navigations) {
int entry_count;
Pickle pickle(static_cast<char*>(data), size);
PickleIterator iter(pickle);
base::Pickle pickle(static_cast<char*>(data), size);
base::PickleIterator iter(pickle);
if (!iter.ReadBool(is_off_the_record) || !iter.ReadInt(&entry_count) ||
!iter.ReadInt(current_entry_index)) {
LOG(ERROR) << "Failed to restore state from byte array (length=" << size
Expand Down Expand Up @@ -258,9 +259,10 @@ bool ExtractNavigationEntries(
<< ").";
return false; // It's dangerous to keep deserializing now, give up.
}
Pickle tab_navigation_pickle(tab_navigation_data,
tab_navigation_data_length);
PickleIterator tab_navigation_pickle_iterator(tab_navigation_pickle);
base::Pickle tab_navigation_pickle(tab_navigation_data,
tab_navigation_data_length);
base::PickleIterator tab_navigation_pickle_iterator(
tab_navigation_pickle);
sessions::SerializedNavigationEntry nav;
if (!nav.ReadFromPickle(&tab_navigation_pickle_iterator))
return false; // If we failed to read a navigation, give up on others.
Expand Down Expand Up @@ -321,7 +323,7 @@ ScopedJavaLocalRef<jobject> WebContentsState::WriteNavigationsAsByteBuffer(
bool is_off_the_record,
const std::vector<content::NavigationEntry*>& navigations,
int current_entry) {
Pickle pickle;
base::Pickle pickle;
if (!WriteStateHeaderToPickle(is_off_the_record, navigations.size(),
current_entry, &pickle)) {
LOG(ERROR) << "Failed to serialize tab state (entry count=" <<
Expand All @@ -333,7 +335,7 @@ ScopedJavaLocalRef<jobject> WebContentsState::WriteNavigationsAsByteBuffer(
for (size_t i = 0; i < navigations.size(); ++i) {
// Write each SerializedNavigationEntry as a separate pickle to avoid
// optional reads of one tab bleeding into the next tab's data.
Pickle tab_navigation_pickle;
base::Pickle tab_navigation_pickle;
// Max size taken from BaseSessionService::CreateUpdateTabNavigationCommand.
static const size_t max_state_size =
std::numeric_limits<sessions::SessionCommand::size_type>::max() - 1024;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class QuerySelectorHandler : public content::WebContentsObserver {

// There may be several requests in flight; check this response matches.
int message_request_id = 0;
PickleIterator iter(message);
base::PickleIterator iter(message);
if (!iter.ReadInt(&message_request_id))
return false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ bool PageCaptureSaveAsMHTMLFunction::OnMessageReceived(
return false;

int message_request_id;
PickleIterator iter(message);
base::PickleIterator iter(message);
if (!iter.ReadInt(&message_request_id)) {
NOTREACHED() << "malformed extension message";
return true;
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/extensions/extension_action.cc
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ bool ExtensionAction::ParseIconFromCanvasDictionary(
} else {
continue;
}
PickleIterator iter(pickle);
base::PickleIterator iter(pickle);
SkBitmap bitmap;
if (!IPC::ReadParam(&pickle, &iter, &bitmap))
return false;
Expand Down
6 changes: 3 additions & 3 deletions chrome/browser/media/webrtc_log_uploader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ void WebRtcLogUploader::UploadStoredLog(
.AddExtension(FILE_PATH_LITERAL(".meta"));
if (base::ReadFileToString(meta_path, &meta_data_contents) &&
!meta_data_contents.empty()) {
Pickle pickle(&meta_data_contents[0], meta_data_contents.size());
PickleIterator it(pickle);
base::Pickle pickle(&meta_data_contents[0], meta_data_contents.size());
base::PickleIterator it(pickle);
std::string key, value;
while (it.ReadString(&key) && it.ReadString(&value))
(*meta_data.get())[key] = value;
Expand Down Expand Up @@ -296,7 +296,7 @@ void WebRtcLogUploader::LoggingStoppedDoStore(
}

if (meta_data.get() && !meta_data->empty()) {
Pickle pickle;
base::Pickle pickle;
for (const auto& it : *meta_data.get()) {
pickle.WriteString(it.first);
pickle.WriteString(it.second);
Expand Down
24 changes: 12 additions & 12 deletions chrome/browser/password_manager/native_backend_kwallet_x.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ bool CompareForms(const autofill::PasswordForm& a,
bool CheckSerializedValue(const uint8_t* byte_array,
size_t length,
const std::string& realm) {
const Pickle::Header* header =
reinterpret_cast<const Pickle::Header*>(byte_array);
const base::Pickle::Header* header =
reinterpret_cast<const base::Pickle::Header*>(byte_array);
if (length < sizeof(*header) ||
header->payload_size > length - sizeof(*header)) {
LOG(WARNING) << "Invalid KWallet entry detected (realm: " << realm << ")";
Expand All @@ -79,7 +79,7 @@ bool CheckSerializedValue(const uint8_t* byte_array,

// Convenience function to read a GURL from a Pickle. Assumes the URL has
// been written as a UTF-8 string. Returns true on success.
bool ReadGURL(PickleIterator* iter, bool warn_only, GURL* url) {
bool ReadGURL(base::PickleIterator* iter, bool warn_only, GURL* url) {
std::string url_string;
if (!iter->ReadString(&url_string)) {
if (!warn_only)
Expand Down Expand Up @@ -113,12 +113,12 @@ void LogDeserializationWarning(int version,
// as either size when reading old pickles that fail to deserialize using the
// native size. Returns true on success.
bool DeserializeValueSize(const std::string& signon_realm,
const PickleIterator& init_iter,
const base::PickleIterator& init_iter,
int version,
bool size_32,
bool warn_only,
ScopedVector<autofill::PasswordForm>* forms) {
PickleIterator iter = init_iter;
base::PickleIterator iter = init_iter;

size_t count = 0;
if (size_32) {
Expand Down Expand Up @@ -235,7 +235,7 @@ bool DeserializeValueSize(const std::string& signon_realm,

// Serializes a list of PasswordForms to be stored in the wallet.
void SerializeValue(const std::vector<autofill::PasswordForm*>& forms,
Pickle* pickle) {
base::Pickle* pickle) {
pickle->WriteInt(kPickleVersion);
pickle->WriteSizeT(forms.size());
for (autofill::PasswordForm* form : forms) {
Expand Down Expand Up @@ -637,7 +637,7 @@ bool NativeBackendKWallet::GetLoginsList(
}

// Can't we all just agree on whether bytes are signed or not? Please?
Pickle pickle(reinterpret_cast<const char*>(bytes), length);
base::Pickle pickle(reinterpret_cast<const char*>(bytes), length);
*forms = DeserializeValue(signon_realm, pickle);
}

Expand Down Expand Up @@ -719,7 +719,7 @@ bool NativeBackendKWallet::GetAllLogins(
continue;

// Can't we all just agree on whether bytes are signed or not? Please?
Pickle pickle(reinterpret_cast<const char*>(bytes), length);
base::Pickle pickle(reinterpret_cast<const char*>(bytes), length);
AppendSecondToFirst(forms, DeserializeValue(signon_realm, pickle));
}
return true;
Expand Down Expand Up @@ -756,7 +756,7 @@ bool NativeBackendKWallet::SetLoginsList(
return ret == 0;
}

Pickle value;
base::Pickle value;
SerializeValue(forms, &value);

dbus::MethodCall method_call(kKWalletInterface, "writeEntry");
Expand Down Expand Up @@ -856,7 +856,7 @@ bool NativeBackendKWallet::RemoveLoginsBetween(
continue;

// Can't we all just agree on whether bytes are signed or not? Please?
Pickle pickle(reinterpret_cast<const char*>(bytes), length);
base::Pickle pickle(reinterpret_cast<const char*>(bytes), length);
ScopedVector<autofill::PasswordForm> all_forms =
DeserializeValue(signon_realm, pickle);

Expand Down Expand Up @@ -888,8 +888,8 @@ bool NativeBackendKWallet::RemoveLoginsBetween(
// static
ScopedVector<autofill::PasswordForm> NativeBackendKWallet::DeserializeValue(
const std::string& signon_realm,
const Pickle& pickle) {
PickleIterator iter(pickle);
const base::Pickle& pickle) {
base::PickleIterator iter(pickle);

int version = -1;
if (!iter.ReadInt(&version) ||
Expand Down
Loading

0 comments on commit bd4d711

Please sign in to comment.