Skip to content

Commit

Permalink
Autofill work:
Browse files Browse the repository at this point in the history
1. Added a command line swithc to facilitate incremental checking in of autofill code.
2. Autofill profile model associator.
3. Part of the upgrade code.(The part to take the latest changes from server on the legacy type)

Review URL: http://codereview.chromium.org/5126001

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@67189 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
lipalani@chromium.org committed Nov 24, 2010
1 parent 1c06528 commit 54c8336
Show file tree
Hide file tree
Showing 27 changed files with 2,720 additions and 358 deletions.
29 changes: 29 additions & 0 deletions chrome/browser/sync/engine/read_node_mock.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_SYNC_ENGINE_READ_NODE_MOCK_H_
#define CHROME_BROWSER_SYNC_ENGINE_READ_NODE_MOCK_H_
#pragma once

#include <string>

#include "chrome/browser/sync/engine/syncapi.h"
#include "testing/gmock/include/gmock/gmock.h"

class ReadNodeMock : public sync_api::ReadNode {
public:
ReadNodeMock() { }
virtual ~ReadNodeMock() {}
MOCK_METHOD2(InitByClientTagLookup,
bool(syncable::ModelType model_type, const std::string& tag));
MOCK_CONST_METHOD0(GetAutofillProfileSpecifics,
const sync_pb::AutofillProfileSpecifics&());
MOCK_CONST_METHOD0(GetId, int64());
MOCK_CONST_METHOD0(GetFirstChildId, int64());
MOCK_CONST_METHOD0(GetFirstChild, int64());
MOCK_CONST_METHOD0(GetSuccessorId, int64());
MOCK_METHOD1(InitByIdLookup, bool(int64 id));
};
#endif // CHROME_BROWSER_SYNC_ENGINE_READ_NODE_MOCK_H_

11 changes: 11 additions & 0 deletions chrome/browser/sync/engine/syncapi.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ using syncable::Directory;
using syncable::DirectoryManager;
using syncable::Entry;
using syncable::SPECIFICS;
using sync_pb::AutofillProfileSpecifics;

typedef GoogleServiceAuthError AuthError;

Expand Down Expand Up @@ -281,6 +282,11 @@ const sync_pb::AutofillSpecifics& BaseNode::GetAutofillSpecifics() const {
return GetEntry()->Get(SPECIFICS).GetExtension(sync_pb::autofill);
}

const AutofillProfileSpecifics& BaseNode::GetAutofillProfileSpecifics() const {
DCHECK_EQ(GetModelType(), syncable::AUTOFILL_PROFILE);
return GetEntry()->Get(SPECIFICS).GetExtension(sync_pb::autofill_profile);
}

const sync_pb::BookmarkSpecifics& BaseNode::GetBookmarkSpecifics() const {
DCHECK(GetModelType() == syncable::BOOKMARKS);
return GetEntry()->Get(SPECIFICS).GetExtension(sync_pb::bookmark);
Expand Down Expand Up @@ -757,6 +763,11 @@ ReadNode::ReadNode(const BaseTransaction* transaction)
DCHECK(transaction);
}

ReadNode::ReadNode() {
entry_ = NULL;
transaction_ = NULL;
}

ReadNode::~ReadNode() {
delete entry_;
}
Expand Down
24 changes: 19 additions & 5 deletions chrome/browser/sync/engine/syncapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class WriteTransaction;
namespace sync_pb {
class AppSpecifics;
class AutofillSpecifics;
class AutofillProfileSpecifics;
class BookmarkSpecifics;
class EntitySpecifics;
class ExtensionSpecifics;
Expand Down Expand Up @@ -149,7 +150,7 @@ class BaseNode {
// metahandle). These ids are strictly local handles. They will persist
// on this client, but the same object on a different client may have a
// different ID value.
int64 GetId() const;
virtual int64 GetId() const;

// Nodes are hierarchically arranged into a single-rooted tree.
// InitByRootLookup on ReadNode allows access to the root. GetParentId is
Expand Down Expand Up @@ -195,6 +196,9 @@ class BaseNode {
// data. Can only be called if GetModelType() == AUTOFILL.
const sync_pb::AutofillSpecifics& GetAutofillSpecifics() const;

virtual const sync_pb::AutofillProfileSpecifics&
GetAutofillProfileSpecifics() const;

// Getter specific to the NIGORI datatype. Returns protobuf
// data. Can only be called if GetModelType() == NIGORI.
const sync_pb::NigoriSpecifics& GetNigoriSpecifics() const;
Expand Down Expand Up @@ -232,11 +236,11 @@ class BaseNode {

// Return the ID of the node immediately after this in the sibling order.
// For the last node in the ordering, return 0.
int64 GetSuccessorId() const;
virtual int64 GetSuccessorId() const;

// Return the ID of the first child of this node. If this node has no
// children, return 0.
int64 GetFirstChildId() const;
virtual int64 GetFirstChildId() const;

// These virtual accessors provide access to data members of derived classes.
virtual const syncable::Entry* GetEntry() const = 0;
Expand All @@ -256,8 +260,7 @@ class BaseNode {
bool DecryptIfNecessary(syncable::Entry* entry);

private:
// Node is meant for stack use only.
void* operator new(size_t size);
void* operator new(size_t size); // Node is meant for stack use only.

// If this node represents a password, this field will hold the actual
// decrypted password data.
Expand Down Expand Up @@ -457,6 +460,9 @@ class ReadNode : public BaseNode {
virtual const syncable::Entry* GetEntry() const;
virtual const BaseTransaction* GetTransaction() const;

protected:
ReadNode();

private:
void* operator new(size_t size); // Node is meant for stack use only.

Expand Down Expand Up @@ -492,6 +498,8 @@ class BaseTransaction {
explicit BaseTransaction(UserShare* share);
virtual ~BaseTransaction();

BaseTransaction() { lookup_= NULL; }

private:
// A syncable ScopedDirLookup, which is the parent of syncable transactions.
syncable::ScopedDirLookup* lookup_;
Expand Down Expand Up @@ -537,6 +545,12 @@ class WriteTransaction : public BaseTransaction {
virtual syncable::BaseTransaction* GetWrappedTrans() const;
syncable::WriteTransaction* GetWrappedWriteTrans() { return transaction_; }

protected:
WriteTransaction() {}

void SetTransaction(syncable::WriteTransaction* trans) {
transaction_ = trans;}

private:
void* operator new(size_t size); // Transaction is meant for stack use only.

Expand Down
26 changes: 26 additions & 0 deletions chrome/browser/sync/engine/syncapi_mock.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_SYNC_ENGINE_SYNCAPI_MOCK_H_
#define CHROME_BROWSER_SYNC_ENGINE_SYNCAPI_MOCK_H_
#pragma once

#include "chrome/browser/sync/engine/syncapi.h"
#include "chrome/browser/sync/syncable/syncable.h"
#include "chrome/browser/sync/syncable/syncable_mock.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"

using sync_api::WriteTransaction;

class MockWriteTransaction : public sync_api::WriteTransaction {
public:
explicit MockWriteTransaction(Directory* directory)
: sync_api::WriteTransaction() {
this->SetTransaction(new MockSyncableWriteTransaction(directory));
}
};

#endif // CHROME_BROWSER_SYNC_ENGINE_SYNCAPI_MOCK_H_

Loading

0 comments on commit 54c8336

Please sign in to comment.