| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/pickle.h" | 9 #include "base/pickle.h" |
| 10 #include "base/stl_util.h" | 10 #include "base/stl_util.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 const std::string& str) { | 45 const std::string& str) { |
| 46 int num_bytes = str.size() * sizeof(char); | 46 int num_bytes = str.size() * sizeof(char); |
| 47 if (*bytes_written + num_bytes < max_bytes) { | 47 if (*bytes_written + num_bytes < max_bytes) { |
| 48 *bytes_written += num_bytes; | 48 *bytes_written += num_bytes; |
| 49 pickle.WriteString(str); | 49 pickle.WriteString(str); |
| 50 } else { | 50 } else { |
| 51 pickle.WriteString(std::string()); | 51 pickle.WriteString(std::string()); |
| 52 } | 52 } |
| 53 } | 53 } |
| 54 | 54 |
| 55 // string16 version of WriteStringToPickle. | |
| 56 void WriteString16ToPickle(Pickle& pickle, int* bytes_written, int max_bytes, | |
| 57 const string16& str) { | |
| 58 int num_bytes = str.size() * sizeof(char16); | |
| 59 if (*bytes_written + num_bytes < max_bytes) { | |
| 60 *bytes_written += num_bytes; | |
| 61 pickle.WriteString16(str); | |
| 62 } else { | |
| 63 pickle.WriteString16(string16()); | |
| 64 } | |
| 65 } | |
| 66 | |
| 67 } // namespace | 55 } // namespace |
| 68 | 56 |
| 69 // Delay between when a command is received, and when we save it to the | 57 // Delay between when a command is received, and when we save it to the |
| 70 // backend. | 58 // backend. |
| 71 static const int kSaveDelayMS = 2500; | 59 static const int kSaveDelayMS = 2500; |
| 72 | 60 |
| 73 // static | 61 // static |
| 74 const int BaseSessionService::max_persist_navigation_count = 6; | 62 const int BaseSessionService::max_persist_navigation_count = 6; |
| 75 | 63 |
| 76 BaseSessionService::BaseSessionService(SessionType type, | 64 BaseSessionService::BaseSessionService(SessionType type, |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 296 // has gone away (around shutdown time) or if we're running as | 284 // has gone away (around shutdown time) or if we're running as |
| 297 // part of a unit test that does not set profile_. | 285 // part of a unit test that does not set profile_. |
| 298 task.Run(); | 286 task.Run(); |
| 299 return true; | 287 return true; |
| 300 } | 288 } |
| 301 } | 289 } |
| 302 | 290 |
| 303 bool BaseSessionService::RunningInProduction() const { | 291 bool BaseSessionService::RunningInProduction() const { |
| 304 return profile_ && BrowserThread::IsMessageLoopValid(BrowserThread::FILE); | 292 return profile_ && BrowserThread::IsMessageLoopValid(BrowserThread::FILE); |
| 305 } | 293 } |
| OLD | NEW |