Make sure webview uses embedder display DPI.
[chromium-blink-merge.git] / sync / sessions / sync_session.cc
blob2e82dae0f3110965a568c56a22b4a9283c89bd5d
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
3 // found in the LICENSE file.
5 #include "sync/sessions/sync_session.h"
7 #include <algorithm>
8 #include <iterator>
10 #include "base/logging.h"
11 #include "sync/internal_api/public/base/model_type.h"
12 #include "sync/internal_api/public/engine/model_safe_worker.h"
13 #include "sync/syncable/directory.h"
15 namespace syncer {
16 namespace sessions {
18 SyncSession::SyncSession(
19 SyncSessionContext* context,
20 Delegate* delegate,
21 const SyncSourceInfo& source)
22 : context_(context),
23 source_(source),
24 delegate_(delegate) {
25 status_controller_.reset(new StatusController());
28 SyncSession::~SyncSession() {}
30 SyncSessionSnapshot SyncSession::TakeSnapshot() const {
31 syncable::Directory* dir = context_->directory();
33 ProgressMarkerMap download_progress_markers;
34 for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; ++i) {
35 ModelType type(ModelTypeFromInt(i));
36 dir->GetDownloadProgressAsString(type, &download_progress_markers[type]);
39 std::vector<int> num_entries_by_type(MODEL_TYPE_COUNT, 0);
40 std::vector<int> num_to_delete_entries_by_type(MODEL_TYPE_COUNT, 0);
41 dir->CollectMetaHandleCounts(&num_entries_by_type,
42 &num_to_delete_entries_by_type);
44 SyncSessionSnapshot snapshot(
45 status_controller_->model_neutral_state(),
46 download_progress_markers,
47 delegate_->IsSyncingCurrentlySilenced(),
48 status_controller_->num_encryption_conflicts(),
49 status_controller_->num_hierarchy_conflicts(),
50 status_controller_->num_server_conflicts(),
51 source_,
52 context_->notifications_enabled(),
53 dir->GetEntriesCount(),
54 status_controller_->sync_start_time(),
55 num_entries_by_type,
56 num_to_delete_entries_by_type);
58 return snapshot;
61 void SyncSession::SendEventNotification(SyncEngineEvent::EventCause cause) {
62 SyncEngineEvent event(cause);
63 event.snapshot = TakeSnapshot();
65 DVLOG(1) << "Sending event with snapshot: " << event.snapshot.ToString();
66 context()->NotifyListeners(event);
69 } // namespace sessions
70 } // namespace syncer