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

Side by Side Diff: chrome/browser/sync/glue/session_model_associator.h

Issue 6465005: [Sync] Initial support for encrypting any datatype (no UI hookup yet). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase + small fix Created 9 years, 10 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #ifndef CHROME_BROWSER_SYNC_GLUE_SESSION_MODEL_ASSOCIATOR_H_ 5 #ifndef CHROME_BROWSER_SYNC_GLUE_SESSION_MODEL_ASSOCIATOR_H_
6 #define CHROME_BROWSER_SYNC_GLUE_SESSION_MODEL_ASSOCIATOR_H_ 6 #define CHROME_BROWSER_SYNC_GLUE_SESSION_MODEL_ASSOCIATOR_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/format_macros.h"
14 #include "base/gtest_prod_util.h" 15 #include "base/gtest_prod_util.h"
15 #include "base/observer_list.h" 16 #include "base/observer_list.h"
16 #include "base/scoped_vector.h" 17 #include "base/scoped_vector.h"
17 #include "base/string_util.h" 18 #include "base/string_util.h"
18 #include "base/threading/non_thread_safe.h" 19 #include "base/threading/non_thread_safe.h"
19 #include "base/utf_string_conversions.h" 20 #include "base/utf_string_conversions.h"
20 #include "chrome/browser/browser_window.h" 21 #include "chrome/browser/browser_window.h"
21 #include "chrome/browser/sessions/session_id.h" 22 #include "chrome/browser/sessions/session_id.h"
22 #include "chrome/browser/sessions/session_service.h" 23 #include "chrome/browser/sessions/session_service.h"
23 #include "chrome/browser/sessions/session_types.h" 24 #include "chrome/browser/sessions/session_types.h"
(...skipping 22 matching lines...) Expand all
46 static const char kSessionsTag[] = "google_chrome_sessions"; 47 static const char kSessionsTag[] = "google_chrome_sessions";
47 48
48 // Contains all logic for associating the Chrome sessions model and 49 // Contains all logic for associating the Chrome sessions model and
49 // the sync sessions model. 50 // the sync sessions model.
50 class SessionModelAssociator 51 class SessionModelAssociator
51 : public PerDataTypeAssociatorInterface<TabContents, size_t>, 52 : public PerDataTypeAssociatorInterface<TabContents, size_t>,
52 public base::NonThreadSafe { 53 public base::NonThreadSafe {
53 public: 54 public:
54 // Does not take ownership of sync_service. 55 // Does not take ownership of sync_service.
55 explicit SessionModelAssociator(ProfileSyncService* sync_service); 56 explicit SessionModelAssociator(ProfileSyncService* sync_service);
57 SessionModelAssociator(ProfileSyncService* sync_service,
58 bool setup_for_test);
56 virtual ~SessionModelAssociator(); 59 virtual ~SessionModelAssociator();
57 60
58 // The has_nodes out parameter is set to true if the sync model has 61 // The has_nodes out parameter is set to true if the sync model has
59 // nodes other than the permanent tagged nodes. The method may 62 // nodes other than the permanent tagged nodes. The method may
60 // return false if an error occurred. 63 // return false if an error occurred.
61 virtual bool SyncModelHasUserCreatedNodes(bool* has_nodes); 64 virtual bool SyncModelHasUserCreatedNodes(bool* has_nodes);
62 65
63 // AssociatorInterface and PerDataTypeAssociator Interface implementation. 66 // AssociatorInterface and PerDataTypeAssociator Interface implementation.
64 virtual void AbortAssociation() { 67 virtual void AbortAssociation() {
65 // No implementation needed, this associator runs on the main thread. 68 // No implementation needed, this associator runs on the main thread.
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 // SessionTab*'s. 297 // SessionTab*'s.
295 void DeleteForeignSessions(); 298 void DeleteForeignSessions();
296 299
297 // Determine if a window is of a type we're interested in syncing. 300 // Determine if a window is of a type we're interested in syncing.
298 static bool ShouldSyncWindowType(const Browser::Type& type); 301 static bool ShouldSyncWindowType(const Browser::Type& type);
299 302
300 // Build a sync tag from tab_node_id. 303 // Build a sync tag from tab_node_id.
301 static inline std::string TabIdToTag( 304 static inline std::string TabIdToTag(
302 const std::string machine_tag, 305 const std::string machine_tag,
303 size_t tab_node_id) { 306 size_t tab_node_id) {
304 return StringPrintf("%s %lu", 307 return StringPrintf("%s %"PRIuS"",
305 machine_tag.c_str(), static_cast<unsigned long>(tab_node_id)); 308 machine_tag.c_str(), tab_node_id);
306 } 309 }
307 310
308 // Initializes the tag corresponding to this machine. 311 // Initializes the tag corresponding to this machine.
309 void InitializeCurrentMachineTag(sync_api::WriteTransaction* trans); 312 void InitializeCurrentMachineTag(sync_api::WriteTransaction* trans);
310 313
311 // Updates the server data based upon the current client session. If no node 314 // Updates the server data based upon the current client session. If no node
312 // corresponding to this machine exists in the sync model, one is created. 315 // corresponding to this machine exists in the sync model, one is created.
313 void UpdateSyncModelDataFromClient(); 316 void UpdateSyncModelDataFromClient();
314 317
315 // Pulls the current sync model from the sync database and returns true upon 318 // Pulls the current sync model from the sync database and returns true upon
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 TabLinksMap tab_map_; 395 TabLinksMap tab_map_;
393 396
394 ForeignSessionTracker foreign_session_tracker_; 397 ForeignSessionTracker foreign_session_tracker_;
395 398
396 // Weak pointer. 399 // Weak pointer.
397 ProfileSyncService* sync_service_; 400 ProfileSyncService* sync_service_;
398 401
399 // Consumer used to obtain the current session. 402 // Consumer used to obtain the current session.
400 CancelableRequestConsumer consumer_; 403 CancelableRequestConsumer consumer_;
401 404
405 // To avoid certain checks not applicable to tests.
406 bool setup_for_test_;
407
402 DISALLOW_COPY_AND_ASSIGN(SessionModelAssociator); 408 DISALLOW_COPY_AND_ASSIGN(SessionModelAssociator);
403 }; 409 };
404 410
405 } // namespace browser_sync 411 } // namespace browser_sync
406 412
407 #endif // CHROME_BROWSER_SYNC_GLUE_SESSION_MODEL_ASSOCIATOR_H_ 413 #endif // CHROME_BROWSER_SYNC_GLUE_SESSION_MODEL_ASSOCIATOR_H_
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/session_change_processor.cc ('k') | chrome/browser/sync/glue/session_model_associator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698