| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/sessions/base_session_service.h" | 5 #include "chrome/browser/sessions/base_session_service.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/pickle.h" | 8 #include "base/pickle.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
| 11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/sessions/session_backend.h" | 13 #include "chrome/browser/sessions/session_backend.h" |
| 14 #include "chrome/browser/sessions/session_types.h" | 14 #include "chrome/browser/sessions/session_types.h" |
| 15 #include "chrome/common/url_constants.h" | 15 #include "chrome/common/url_constants.h" |
| 16 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
| 17 #include "content/public/browser/navigation_entry.h" | 17 #include "content/public/browser/navigation_entry.h" |
| 18 #include "content/public/common/referrer.h" | 18 #include "content/public/common/referrer.h" |
| 19 #include "webkit/glue/webkit_glue.h" | 19 #include "webkit/glue/webkit_glue.h" |
| 20 | 20 |
| 21 using WebKit::WebReferrerPolicy; |
| 21 using content::BrowserThread; | 22 using content::BrowserThread; |
| 22 using WebKit::WebReferrerPolicy; | 23 using content::NavigationEntry; |
| 23 | 24 |
| 24 // InternalGetCommandsRequest ------------------------------------------------- | 25 // InternalGetCommandsRequest ------------------------------------------------- |
| 25 | 26 |
| 26 BaseSessionService::InternalGetCommandsRequest::~InternalGetCommandsRequest() { | 27 BaseSessionService::InternalGetCommandsRequest::~InternalGetCommandsRequest() { |
| 27 STLDeleteElements(&commands); | 28 STLDeleteElements(&commands); |
| 28 } | 29 } |
| 29 | 30 |
| 30 // BaseSessionService --------------------------------------------------------- | 31 // BaseSessionService --------------------------------------------------------- |
| 31 | 32 |
| 32 namespace { | 33 namespace { |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 131 if (pending_reset_) { | 132 if (pending_reset_) { |
| 132 commands_since_reset_ = 0; | 133 commands_since_reset_ = 0; |
| 133 pending_reset_ = false; | 134 pending_reset_ = false; |
| 134 } | 135 } |
| 135 } | 136 } |
| 136 | 137 |
| 137 SessionCommand* BaseSessionService::CreateUpdateTabNavigationCommand( | 138 SessionCommand* BaseSessionService::CreateUpdateTabNavigationCommand( |
| 138 SessionID::id_type command_id, | 139 SessionID::id_type command_id, |
| 139 SessionID::id_type tab_id, | 140 SessionID::id_type tab_id, |
| 140 int index, | 141 int index, |
| 141 const content::NavigationEntry& entry) { | 142 const NavigationEntry& entry) { |
| 142 // Use pickle to handle marshalling. | 143 // Use pickle to handle marshalling. |
| 143 Pickle pickle; | 144 Pickle pickle; |
| 144 pickle.WriteInt(tab_id); | 145 pickle.WriteInt(tab_id); |
| 145 pickle.WriteInt(index); | 146 pickle.WriteInt(index); |
| 146 | 147 |
| 147 // We only allow navigations up to 63k (which should be completely | 148 // We only allow navigations up to 63k (which should be completely |
| 148 // reasonable). On the off chance we get one that is too big, try to | 149 // reasonable). On the off chance we get one that is too big, try to |
| 149 // keep the url. | 150 // keep the url. |
| 150 | 151 |
| 151 // Bound the string data (which is variable length) to | 152 // Bound the string data (which is variable length) to |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 if (profile_ && BrowserThread::IsMessageLoopValid(BrowserThread::FILE)) { | 283 if (profile_ && BrowserThread::IsMessageLoopValid(BrowserThread::FILE)) { |
| 283 return BrowserThread::PostTask(BrowserThread::FILE, from_here, task); | 284 return BrowserThread::PostTask(BrowserThread::FILE, from_here, task); |
| 284 } else { | 285 } else { |
| 285 // Fall back to executing on the main thread if the file thread | 286 // Fall back to executing on the main thread if the file thread |
| 286 // has gone away (around shutdown time) or if we're running as | 287 // has gone away (around shutdown time) or if we're running as |
| 287 // part of a unit test that does not set profile_. | 288 // part of a unit test that does not set profile_. |
| 288 task.Run(); | 289 task.Run(); |
| 289 return true; | 290 return true; |
| 290 } | 291 } |
| 291 } | 292 } |
| OLD | NEW |