cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / components / sessions / session_types.cc
blob4d2e9ac93ccd6391b72345b7af8ef0ec9502f1e0
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
3 // found in the LICENSE file.
5 #include "components/sessions/session_types.h"
7 #include "base/basictypes.h"
8 #include "base/stl_util.h"
9 #include "components/sessions/session_command.h"
11 namespace sessions {
13 //using class SerializedNavigationEntry;
15 // SessionTab -----------------------------------------------------------------
17 SessionTab::SessionTab()
18 : tab_visual_index(-1),
19 current_navigation_index(-1),
20 pinned(false) {
23 SessionTab::~SessionTab() {
26 void SessionTab::SetFromSyncData(const sync_pb::SessionTab& sync_data,
27 base::Time timestamp) {
28 window_id.set_id(sync_data.window_id());
29 tab_id.set_id(sync_data.tab_id());
30 tab_visual_index = sync_data.tab_visual_index();
31 current_navigation_index = sync_data.current_navigation_index();
32 pinned = sync_data.pinned();
33 extension_app_id = sync_data.extension_app_id();
34 user_agent_override.clear();
35 this->timestamp = timestamp;
36 navigations.clear();
37 for (int i = 0; i < sync_data.navigation_size(); ++i) {
38 navigations.push_back(
39 SerializedNavigationEntry::FromSyncData(i, sync_data.navigation(i)));
41 session_storage_persistent_id.clear();
42 variation_ids.clear();
43 for (int i = 0; i < sync_data.variation_id_size(); ++i)
44 variation_ids.push_back(sync_data.variation_id(i));
47 sync_pb::SessionTab SessionTab::ToSyncData() const {
48 sync_pb::SessionTab sync_data;
49 sync_data.set_tab_id(tab_id.id());
50 sync_data.set_window_id(window_id.id());
51 sync_data.set_tab_visual_index(tab_visual_index);
52 sync_data.set_current_navigation_index(current_navigation_index);
53 sync_data.set_pinned(pinned);
54 sync_data.set_extension_app_id(extension_app_id);
55 for (const SerializedNavigationEntry& navigation : navigations) {
56 *sync_data.add_navigation() = navigation.ToSyncData();
58 for (const variations::VariationID variation_id : variation_ids) {
59 sync_data.add_variation_id(variation_id);
61 return sync_data;
64 // SessionWindow ---------------------------------------------------------------
66 SessionWindow::SessionWindow()
67 : selected_tab_index(-1),
68 type(TYPE_TABBED),
69 is_constrained(true),
70 show_state(ui::SHOW_STATE_DEFAULT) {
73 SessionWindow::~SessionWindow() {
74 STLDeleteElements(&tabs);
77 sync_pb::SessionWindow SessionWindow::ToSyncData() const {
78 sync_pb::SessionWindow sync_data;
79 sync_data.set_window_id(window_id.id());
80 sync_data.set_selected_tab_index(selected_tab_index);
81 switch (type) {
82 case SessionWindow::TYPE_TABBED:
83 sync_data.set_browser_type(
84 sync_pb::SessionWindow_BrowserType_TYPE_TABBED);
85 break;
86 case SessionWindow::TYPE_POPUP:
87 sync_data.set_browser_type(
88 sync_pb::SessionWindow_BrowserType_TYPE_POPUP);
89 break;
90 default:
91 NOTREACHED() << "Unhandled browser type.";
94 for (size_t i = 0; i < tabs.size(); i++)
95 sync_data.add_tab(tabs[i]->tab_id.id());
97 return sync_data;
100 } // namespace sessions