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

Side by Side Diff: components/sessions/core/persistent_tab_restore_service.cc

Issue 1551433002: Switch to standard integer types in components/, part 3 of 4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more Created 4 years, 11 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 #include "components/sessions/core/persistent_tab_restore_service.h" 5 #include "components/sessions/core/persistent_tab_restore_service.h"
6 6
7 #include <cstring> // memcpy 7 #include <stddef.h>
8 #include <stdint.h>
9 #include <string.h>
10
8 #include <vector> 11 #include <vector>
9 12
10 #include "base/basictypes.h"
11 #include "base/bind.h" 13 #include "base/bind.h"
12 #include "base/compiler_specific.h" 14 #include "base/compiler_specific.h"
13 #include "base/files/file_path.h" 15 #include "base/files/file_path.h"
14 #include "base/logging.h" 16 #include "base/logging.h"
17 #include "base/macros.h"
15 #include "base/memory/ref_counted.h" 18 #include "base/memory/ref_counted.h"
16 #include "base/memory/scoped_vector.h" 19 #include "base/memory/scoped_vector.h"
17 #include "base/stl_util.h" 20 #include "base/stl_util.h"
18 #include "base/task/cancelable_task_tracker.h" 21 #include "base/task/cancelable_task_tracker.h"
19 #include "base/time/time.h" 22 #include "base/time/time.h"
20 #include "components/sessions/core/base_session_service.h" 23 #include "components/sessions/core/base_session_service.h"
21 #include "components/sessions/core/base_session_service_commands.h" 24 #include "components/sessions/core/base_session_service_commands.h"
22 #include "components/sessions/core/base_session_service_delegate.h" 25 #include "components/sessions/core/base_session_service_delegate.h"
23 #include "components/sessions/core/session_command.h" 26 #include "components/sessions/core/session_command.h"
24 #include "components/sessions/core/session_constants.h" 27 #include "components/sessions/core/session_constants.h"
25 28
26 namespace sessions { 29 namespace sessions {
27 30
28 namespace { 31 namespace {
29 32
30 // Only written if the tab is pinned. 33 // Only written if the tab is pinned.
31 typedef bool PinnedStatePayload; 34 typedef bool PinnedStatePayload;
32 35
33 typedef int32 RestoredEntryPayload; 36 typedef int32_t RestoredEntryPayload;
34 37
35 typedef std::map<SessionID::id_type, TabRestoreService::Entry*> IDToEntry; 38 typedef std::map<SessionID::id_type, TabRestoreService::Entry*> IDToEntry;
36 39
37 // Payload used for the start of a tab close. This is the old struct that is 40 // Payload used for the start of a tab close. This is the old struct that is
38 // used for backwards compat when it comes to reading the session files. 41 // used for backwards compat when it comes to reading the session files.
39 struct SelectedNavigationInTabPayload { 42 struct SelectedNavigationInTabPayload {
40 SessionID::id_type id; 43 SessionID::id_type id;
41 int32 index; 44 int32_t index;
42 }; 45 };
43 46
44 // Payload used for the start of a window close. This is the old struct that is 47 // Payload used for the start of a window close. This is the old struct that is
45 // used for backwards compat when it comes to reading the session files. This 48 // used for backwards compat when it comes to reading the session files. This
46 // struct must be POD, because we memset the contents. 49 // struct must be POD, because we memset the contents.
47 struct WindowPayload { 50 struct WindowPayload {
48 SessionID::id_type window_id; 51 SessionID::id_type window_id;
49 int32 selected_tab_index; 52 int32_t selected_tab_index;
50 int32 num_tabs; 53 int32_t num_tabs;
51 }; 54 };
52 55
53 // Payload used for the start of a window close. This struct must be POD, 56 // Payload used for the start of a window close. This struct must be POD,
54 // because we memset the contents. 57 // because we memset the contents.
55 struct WindowPayload2 : WindowPayload { 58 struct WindowPayload2 : WindowPayload {
56 int64 timestamp; 59 int64_t timestamp;
57 }; 60 };
58 61
59 // Payload used for the start of a tab close. 62 // Payload used for the start of a tab close.
60 struct SelectedNavigationInTabPayload2 : SelectedNavigationInTabPayload { 63 struct SelectedNavigationInTabPayload2 : SelectedNavigationInTabPayload {
61 int64 timestamp; 64 int64_t timestamp;
62 }; 65 };
63 66
64 // Used to indicate what has loaded. 67 // Used to indicate what has loaded.
65 enum LoadState { 68 enum LoadState {
66 // Indicates we haven't loaded anything. 69 // Indicates we haven't loaded anything.
67 NOT_LOADED = 1 << 0, 70 NOT_LOADED = 1 << 0,
68 71
69 // Indicates we've asked for the last sessions and tabs but haven't gotten the 72 // Indicates we've asked for the last sessions and tabs but haven't gotten the
70 // result back yet. 73 // result back yet.
71 LOADING = 1 << 2, 74 LOADING = 1 << 2,
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 162
160 // Creates a window close command. 163 // Creates a window close command.
161 static scoped_ptr<SessionCommand> CreateWindowCommand(SessionID::id_type id, 164 static scoped_ptr<SessionCommand> CreateWindowCommand(SessionID::id_type id,
162 int selected_tab_index, 165 int selected_tab_index,
163 int num_tabs, 166 int num_tabs,
164 base::Time timestamp); 167 base::Time timestamp);
165 168
166 // Creates a tab close command. 169 // Creates a tab close command.
167 static scoped_ptr<SessionCommand> CreateSelectedNavigationInTabCommand( 170 static scoped_ptr<SessionCommand> CreateSelectedNavigationInTabCommand(
168 SessionID::id_type tab_id, 171 SessionID::id_type tab_id,
169 int32 index, 172 int32_t index,
170 base::Time timestamp); 173 base::Time timestamp);
171 174
172 // Creates a restore command. 175 // Creates a restore command.
173 static scoped_ptr<SessionCommand> CreateRestoredEntryCommand( 176 static scoped_ptr<SessionCommand> CreateRestoredEntryCommand(
174 SessionID::id_type entry_id); 177 SessionID::id_type entry_id);
175 178
176 // Returns the index to persist as the selected index. This is the same as 179 // Returns the index to persist as the selected index. This is the same as
177 // |tab.current_navigation_index| unless the entry at 180 // |tab.current_navigation_index| unless the entry at
178 // |tab.current_navigation_index| shouldn't be persisted. Returns -1 if no 181 // |tab.current_navigation_index| shouldn't be persisted. Returns -1 if no
179 // valid navigation to persist. 182 // valid navigation to persist.
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 scoped_ptr<SessionCommand> command( 504 scoped_ptr<SessionCommand> command(
502 new SessionCommand(kCommandWindow, sizeof(payload))); 505 new SessionCommand(kCommandWindow, sizeof(payload)));
503 memcpy(command->contents(), &payload, sizeof(payload)); 506 memcpy(command->contents(), &payload, sizeof(payload));
504 return command; 507 return command;
505 } 508 }
506 509
507 // static 510 // static
508 scoped_ptr<SessionCommand> 511 scoped_ptr<SessionCommand>
509 PersistentTabRestoreService::Delegate::CreateSelectedNavigationInTabCommand( 512 PersistentTabRestoreService::Delegate::CreateSelectedNavigationInTabCommand(
510 SessionID::id_type tab_id, 513 SessionID::id_type tab_id,
511 int32 index, 514 int32_t index,
512 base::Time timestamp) { 515 base::Time timestamp) {
513 SelectedNavigationInTabPayload2 payload; 516 SelectedNavigationInTabPayload2 payload;
514 payload.id = tab_id; 517 payload.id = tab_id;
515 payload.index = index; 518 payload.index = index;
516 payload.timestamp = timestamp.ToInternalValue(); 519 payload.timestamp = timestamp.ToInternalValue();
517 scoped_ptr<SessionCommand> command( 520 scoped_ptr<SessionCommand> command(
518 new SessionCommand(kCommandSelectedNavigationInTab, sizeof(payload))); 521 new SessionCommand(kCommandSelectedNavigationInTab, sizeof(payload)));
519 memcpy(command->contents(), &payload, sizeof(payload)); 522 memcpy(command->contents(), &payload, sizeof(payload));
520 return command; 523 return command;
521 } 524 }
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after
991 994
992 TabRestoreService::Entries* PersistentTabRestoreService::mutable_entries() { 995 TabRestoreService::Entries* PersistentTabRestoreService::mutable_entries() {
993 return &helper_.entries_; 996 return &helper_.entries_;
994 } 997 }
995 998
996 void PersistentTabRestoreService::PruneEntries() { 999 void PersistentTabRestoreService::PruneEntries() {
997 helper_.PruneEntries(); 1000 helper_.PruneEntries();
998 } 1001 }
999 1002
1000 } // namespace sessions 1003 } // namespace sessions
OLDNEW
« no previous file with comments | « components/sessions/core/persistent_tab_restore_service.h ('k') | components/sessions/core/serialized_navigation_entry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698