Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Brave syncer #2010

Merged
merged 73 commits into from Aug 20, 2019
Merged

Brave syncer #2010

Changes from 1 commit
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
c423779
Make browser_sync::ProfileSyncService a brave_sync::SyncMessageHandler
darkdh Feb 26, 2019
d08cd5e
Upgrade to 74.0.3729.75
darkdh Apr 11, 2019
5d9fd40
Fixed build on Linux
AlexeyBarabash Apr 12, 2019
5371a9b
Pass icon data
AlexeyBarabash Apr 18, 2019
e7155d4
Migrate from legacy sync
darkdh Apr 18, 2019
2b431d6
Introduce IsFirstLoadedFavicon to avoid favicon loading trigged sendi…
darkdh Apr 20, 2019
22e770b
Remove unused code
darkdh Apr 22, 2019
be43397
Fix Reset bug and prevent shutdown sync thread hanging
darkdh Apr 23, 2019
78e0d85
Implement OnSaveBookmarkOrder from #2326
darkdh Apr 25, 2019
372552b
Redefine order calculation to be simply parent_order + index_in_parent
darkdh Apr 26, 2019
8896428
Fix wrong sync code crash
darkdh Apr 30, 2019
8ca0675
Subclass browser_sync::ProfileSyncService
darkdh May 6, 2019
4972a86
Fix DCHECK failure because of lacking permanent nodes order when
darkdh May 7, 2019
6463250
Handle same index from different devices by order
darkdh May 7, 2019
05731ec
Set user-chosen sync type only when first time sync setup or migrated
darkdh May 9, 2019
4f6ed56
Using MigratedBookmarksVersion >= 2 to check legacy sync migration st…
darkdh May 9, 2019
73627bb
Stub out Control Types
darkdh May 10, 2019
2d4662f
Fix index calculation when applying remote records
darkdh May 13, 2019
5d4d8c2
Migrate BraveSyncServiceTest
darkdh May 16, 2019
57cf686
Add test for SyncerHelper
darkdh May 17, 2019
ed60929
Dont send bookmarks until chain is created. Re-do of brave-core pr#2016
AlexeyBarabash May 20, 2019
a766cdd
C75.0.3770.38 Upgrade
darkdh May 21, 2019
6e31e37
Force DEVICE_INFO to have nudge cycles
AlexeyBarabash May 24, 2019
1db950a
Register brave_sync pref with chromium sync
darkdh May 24, 2019
bd689d0
Consolidate BraveSyncServiceTest
darkdh May 24, 2019
c5fbe1f
Remove manually disable field trail feature
darkdh May 28, 2019
5b0f830
lint fix
darkdh May 28, 2019
1e55ab6
Android build fix
darkdh May 29, 2019
a524251
Move BraveSyncClient to BraveProfileSyncService
darkdh May 29, 2019
e2617dc
Replace brave_sync::BraveSyncService::is_enabled() with switches::IsB…
darkdh May 29, 2019
bf1becb
Window release build deps fix
darkdh May 31, 2019
902017f
single dep encapsulation
darkdh Jun 12, 2019
2b2e2e5
IsSyncAllowedByFlag chromium_src override
darkdh Jun 12, 2019
baf9003
remove GetAsBraveProfileSyncServiceForProfile and use ENABLE_BRAVE_SY…
darkdh Jun 12, 2019
5591700
friend BraveProfileSyncService
darkdh Jun 12, 2019
23fdeed
Using SyncEngineHost to avoid storing poll/nudge delegates
darkdh Jun 13, 2019
0ff789f
Move brave_sync::RegisterProfilePrefs to brave::RegisterProfilePrefs
darkdh Jun 13, 2019
d970cad
Chromium override SyncerProtoUtil
darkdh Jun 16, 2019
38b42cf
Update 75.0.3770.90 patch
darkdh Jun 18, 2019
48d6aaf
clean up patches
darkdh Jun 19, 2019
f3f381c
add guards for ENABLE_BRAVE_SYNC
bridiver Jun 19, 2019
f4a013b
Fixed Linux build
AlexeyBarabash Jun 20, 2019
60d93e0
BraveProfileSyncService => BraveProfileSyncServiceImpl; BraveProfileS…
AlexeyBarabash Jun 25, 2019
3fbacc7
Ignore records from ourselves
AlexeyBarabash Jun 25, 2019
2176464
Send records after at least 30 sec after chain creation
AlexeyBarabash Jun 25, 2019
b0c8c49
Fix tests for send records after at least 30 sec after chain creation
AlexeyBarabash Jun 25, 2019
ee2fbf5
Patches for attach/detach behaviour for WriteTransaction
AlexeyBarabash Jun 25, 2019
0aad976
Sort bookmarks in BookmarkChangeProcessor::ApplyChangesFromSyncModel …
AlexeyBarabash Jun 25, 2019
eb2dd0b
Update DEPS to contain "Ignore records from SQS which where seen in S3"
AlexeyBarabash Jun 25, 2019
5eecbd2
Use title or customeTitle, non empty value
AlexeyBarabash Jul 1, 2019
a04cb32
Fix for crash with bookmark position from older sync client (android)
AlexeyBarabash Jul 9, 2019
0f79073
Update 76.0.3809.62 patches
darkdh Jul 15, 2019
1338103
Remove BRAVE_SHOULD_SHOW_SIGNIN_PROMO_SHORT_CIRCUIT_TO_FALSE and lint…
darkdh Jul 16, 2019
7fcee9d
Fix enable_brave_sync=false
darkdh Jul 17, 2019
c3fc745
Check DISABLE_REASON_ENTERPRISE_POLICY in ShouldShowSignInPromo and f…
darkdh Jul 17, 2019
97d0eca
Passive resend unconfirmed records
darkdh Jul 23, 2019
4b2b835
Native code for bookmark order calculations
AlexeyBarabash Jul 24, 2019
1c2ba0a
Testcases for native bookmark order calculations
AlexeyBarabash Jul 24, 2019
91e5d05
Sync reset reenable (#3038)
darkdh Jul 31, 2019
9677876
Exponentials resend periods (#2986)
darkdh Aug 8, 2019
412e408
Bookmarks positioning by order strings
AlexeyBarabash Jul 24, 2019
e1104e2
Updated testcases for positioning by orders
AlexeyBarabash Jul 24, 2019
5cab8ba
In case of equal orders use object_id
AlexeyBarabash Aug 6, 2019
4969766
Test case for use object_id when orders are equal
AlexeyBarabash Aug 6, 2019
6eef9c2
Ignore move events during extensive changes
AlexeyBarabash Aug 6, 2019
6636c1d
Network changes and Reset handling
darkdh Aug 13, 2019
b376e3f
Using UniquePosition for bookmark order by position_in_parent
darkdh Aug 14, 2019
ce62ff9
Maintain SyncEntityInfo in bookmark node's meta info for legacy sync
darkdh Aug 15, 2019
99b97f5
Review Feedback (1)
darkdh Aug 16, 2019
220d604
Review Feedback (2)
darkdh Aug 16, 2019
99f29b6
Use WaitableEvent::TimedWait as fail-safe
darkdh Aug 16, 2019
8b24310
Review feedback (3)
darkdh Aug 17, 2019
42c5c31
Do not send meta info until all platforms support necessary chromium
darkdh Aug 19, 2019
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Review Feedback (2)

  1. Remvoe weak_ptr for syncer and make sure get_record_cb_ won't get
  called when sync_thread is not running
  2. Remove unnecessary forward declaration
  • Loading branch information
darkdh committed Aug 16, 2019
commit 220d6042e1ffe25f5f02d8e8aef3211b1a952ed6
@@ -4,24 +4,15 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */

#include "components/sync/driver/profile_sync_service.h"

class Profile;

namespace {
std::unique_ptr<syncer::ProfileSyncService> BraveBuildServiceInstanceFor(
Profile* profile,
syncer::ProfileSyncService::InitParams init_params);
} // namespace

#include "../../../../../chrome/browser/sync/profile_sync_service_factory.cc" // NOLINT

#include "brave/components/brave_sync/buildflags/buildflags.h"

#if BUILDFLAG(ENABLE_BRAVE_SYNC)
#include "brave/components/brave_sync/brave_profile_sync_service_impl.h"
using brave_sync::BraveProfileSyncServiceImpl;
#endif

class Profile;

namespace {

std::unique_ptr<syncer::ProfileSyncService> BraveBuildServiceInstanceFor(
@@ -36,3 +27,5 @@ std::unique_ptr<syncer::ProfileSyncService> BraveBuildServiceInstanceFor(
}

} // namespace

#include "../../../../../chrome/browser/sync/profile_sync_service_factory.cc" // NOLINT
@@ -46,13 +46,14 @@ void OnPollSyncCycleOnOwnerThread(base::WeakPtr<SyncEngineImpl> sync_engine,
if (sync_engine.get())
static_cast<BraveProfileSyncService*>(
BraveGetSyncEngineHost(sync_engine.get()))
->OnPollSyncCycle(cb, wevent);
->OnPollSyncCycle(std::move(cb), wevent);
}

void OnPollSyncCycle(WeakHandle<SyncEngineImpl> sync_engine_impl,
GetRecordsCallback cb,
base::WaitableEvent* wevent) {
sync_engine_impl.Call(FROM_HERE, &OnPollSyncCycleOnOwnerThread, cb, wevent);
sync_engine_impl.Call(FROM_HERE, &OnPollSyncCycleOnOwnerThread,
base::Passed(&cb), wevent);
}
#endif

@@ -43,7 +43,7 @@ void OnPollSyncCycle(base::WeakPtr<ProfileSyncService> profile_sync_service,
base::WaitableEvent* wevent) {
if (profile_sync_service.get()) {
static_cast<BraveProfileSyncService*>(profile_sync_service.get())
->OnPollSyncCycle(cb, wevent);
->OnPollSyncCycle(std::move(cb), wevent);
}
}
#endif
@@ -18,7 +18,7 @@ void SyncSchedulerImpl::OnNudgeSyncCycle(
void SyncSchedulerImpl::OnPollSyncCycle(brave_sync::GetRecordsCallback cb,
base::WaitableEvent* wevent) {
DCHECK(poll_sync_cycle_delegate_function_);
poll_sync_cycle_delegate_function_.Run(cb, wevent);
poll_sync_cycle_delegate_function_.Run(std::move(cb), wevent);
}

} // namespace syncer
@@ -8,6 +8,8 @@
#include <memory>
#include <utility>

#include "base/bind.h"

#include "../../../../../components/sync/engine_impl/syncer.cc" // NOLINT

namespace syncer {
@@ -23,9 +25,9 @@ void Syncer::DownloadBraveRecords(SyncCycle* cycle) {
// syncer will be alive as long as sync is enabled
brave_records_.reset();
brave_sync::GetRecordsCallback on_get_records =
base::BindRepeating(&Syncer::OnGetRecords, AsWeakPtr());
base::BindOnce(&Syncer::OnGetRecords, base::Unretained(this));
base::WaitableEvent wevent;
cycle->delegate()->OnPollSyncCycle(on_get_records, &wevent);
cycle->delegate()->OnPollSyncCycle(std::move(on_get_records), &wevent);
// Make sure OnGetRecords will be the next task on sync thread
wevent.Wait();
}
@@ -6,7 +6,6 @@
#ifndef BRAVE_CHROMIUM_SRC_COMPONENTS_SYNC_ENGINE_IMPL_SYNCER_H_
#define BRAVE_CHROMIUM_SRC_COMPONENTS_SYNC_ENGINE_IMPL_SYNCER_H_

#include "base/memory/weak_ptr.h"
#include "brave/components/brave_sync/jslib_messages.h"
#include "brave/components/brave_sync/jslib_messages_fwd.h"

@@ -128,7 +128,7 @@ std::unique_ptr<SyncRecord> CreateDeleteBookmarkByObjectId(
void DoDispatchGetRecordsCallback(
GetRecordsCallback cb,
std::unique_ptr<brave_sync::RecordsList> records) {
cb.Run(std::move(records));
std::move(cb).Run(std::move(records));
}

void AddSyncEntityInfo(jslib::Bookmark* bookmark,
@@ -301,7 +301,7 @@ void BraveProfileSyncServiceImpl::OnResetSync() {
ResetSyncInternal();
} else {
// We have to send delete record and wait for library deleted response then
// we can reset it by ResetInternal()
// we can reset it by ResetSyncInternal()
const std::string device_id = brave_sync_prefs_->GetThisDeviceId();
OnDeleteDevice(device_id);
reseting_ = true;
@@ -524,8 +524,9 @@ void BraveProfileSyncServiceImpl::OnResolvedSyncRecords(
// Send records to syncer
if (get_record_cb_)
sync_thread_->task_runner()->PostTask(
FROM_HERE, base::BindOnce(&DoDispatchGetRecordsCallback,
get_record_cb_, std::move(records)));
FROM_HERE,
base::BindOnce(&DoDispatchGetRecordsCallback,
std::move(get_record_cb_), std::move(records)));
SignalWaitableEvent();
} else if (category_name == kHistorySites) {
NOTIMPLEMENTED();
@@ -608,6 +609,7 @@ void BraveProfileSyncServiceImpl::NotifyHaveSyncWords(
}

void BraveProfileSyncServiceImpl::ResetSyncInternal() {
SignalWaitableEvent();
brave_sync_prefs_->SetPrevSeed(brave_sync_prefs_->GetSeed());

brave_sync_prefs_->Clear();
@@ -912,7 +914,7 @@ void BraveProfileSyncServiceImpl::OnPollSyncCycle(GetRecordsCallback cb,
return;
}

get_record_cb_ = cb;
get_record_cb_ = std::move(cb);
wevent_ = wevent;

const bool bookmarks = brave_sync_prefs_->GetSyncBookmarksEnabled();
@@ -923,6 +925,7 @@ void BraveProfileSyncServiceImpl::OnPollSyncCycle(GetRecordsCallback cb,
}

void BraveProfileSyncServiceImpl::SignalWaitableEvent() {
std::move(get_record_cb_);
if (wevent_) {
wevent_->Signal();
wevent_ = nullptr;
@@ -40,10 +40,11 @@ typedef std::vector<SyncRecordAndExistingPtr> SyncRecordAndExistingList;

using Uint8Array = std::vector<unsigned char>;
using GetRecordsCallback =
base::RepeatingCallback<void(std::unique_ptr<RecordsList>)>;
using NudgeSyncCycleDelegate = base::Callback<void(RecordsListPtr)>;
base::OnceCallback<void(std::unique_ptr<RecordsList>)>;
using NudgeSyncCycleDelegate = base::RepeatingCallback<void(RecordsListPtr)>;
using PollSyncCycleDelegate =
base::Callback<void(GetRecordsCallback, base::WaitableEvent* wevent)>;
base::RepeatingCallback<void(GetRecordsCallback,
base::WaitableEvent* wevent)>;

} // namespace brave_sync

@@ -1,16 +1,7 @@
diff --git a/components/sync/engine_impl/syncer.h b/components/sync/engine_impl/syncer.h
index 23b389eada81c850c3a8856678d046e599a060da..48654f4c09558ea4d0ac246ebe16178019b30a0e 100644
index 23b389eada81c850c3a8856678d046e599a060da..30ce667ae1e00e51bf4f227084da8f4ca30f8dc2 100644
--- a/components/sync/engine_impl/syncer.h
+++ b/components/sync/engine_impl/syncer.h
@@ -32,7 +32,7 @@ class SyncCycle;
// A Syncer instance expects to run on a dedicated thread. Calls to SyncShare()
// may take an unbounded amount of time because it may block on network I/O, on
// lock contention, or on tasks posted to other threads.
-class Syncer {
+class Syncer : public base::SupportsWeakPtr<Syncer> {
public:
explicit Syncer(CancelationSignal* cancelation_signal);
virtual ~Syncer();
@@ -94,6 +94,7 @@ class Syncer {
// Whether the syncer is in the middle of a sync attempt.
bool is_syncing_;
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.