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

Side by Side Diff: chrome/browser/sessions/session_service.cc

Issue 8873021: (Base)SessionService: Remove dead code which was only used by the unit tests. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebased. Created 9 years 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 (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/session_service.h" 5 #include "chrome/browser/sessions/session_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 class InternalSessionRequest 77 class InternalSessionRequest
78 : public BaseSessionService::InternalGetCommandsRequest { 78 : public BaseSessionService::InternalGetCommandsRequest {
79 public: 79 public:
80 InternalSessionRequest( 80 InternalSessionRequest(
81 const CallbackType& callback, 81 const CallbackType& callback,
82 const SessionService::SessionCallback& real_callback) 82 const SessionService::SessionCallback& real_callback)
83 : BaseSessionService::InternalGetCommandsRequest(callback), 83 : BaseSessionService::InternalGetCommandsRequest(callback),
84 real_callback(real_callback) { 84 real_callback(real_callback) {
85 } 85 }
86 86
87 // The callback supplied to GetLastSession and GetCurrentSession. 87 // The callback supplied to GetLastSession.
88 SessionService::SessionCallback real_callback; 88 SessionService::SessionCallback real_callback;
89 89
90 private: 90 private:
91 ~InternalSessionRequest() {} 91 ~InternalSessionRequest() {}
92 92
93 DISALLOW_COPY_AND_ASSIGN(InternalSessionRequest); 93 DISALLOW_COPY_AND_ASSIGN(InternalSessionRequest);
94 }; 94 };
95 95
96 // Various payload structures. 96 // Various payload structures.
97 struct ClosedPayload { 97 struct ClosedPayload {
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 CancelableRequestConsumerBase* consumer, 417 CancelableRequestConsumerBase* consumer,
418 const SessionCallback& callback) { 418 const SessionCallback& callback) {
419 return ScheduleGetLastSessionCommands( 419 return ScheduleGetLastSessionCommands(
420 new InternalSessionRequest( 420 new InternalSessionRequest(
421 base::Bind(&SessionService::OnGotSessionCommands, 421 base::Bind(&SessionService::OnGotSessionCommands,
422 base::Unretained(this)), 422 base::Unretained(this)),
423 callback), 423 callback),
424 consumer); 424 consumer);
425 } 425 }
426 426
427 SessionService::Handle SessionService::GetCurrentSession(
428 CancelableRequestConsumerBase* consumer,
429 const SessionCallback& callback) {
430 if (pending_window_close_ids_.empty()) {
431 // If there are no pending window closes, we can get the current session
432 // from memory.
433 scoped_refptr<InternalSessionRequest> request(new InternalSessionRequest(
434 base::Bind(&SessionService::OnGotSessionCommands,
435 base::Unretained(this)),
436 callback));
437 AddRequest(request, consumer);
438 IdToRange tab_to_available_range;
439 std::set<SessionID::id_type> windows_to_track;
440 BuildCommandsFromBrowsers(&(request->commands),
441 &tab_to_available_range,
442 &windows_to_track);
443 request->ForwardResult(request->handle(), request);
444 return request->handle();
445 } else {
446 // If there are pending window closes, read the current session from disk.
447 return ScheduleGetCurrentSessionCommands(
448 new InternalSessionRequest(
449 base::Bind(&SessionService::OnGotSessionCommands,
450 base::Unretained(this)),
451 callback),
452 consumer);
453 }
454 }
455
456 void SessionService::Save() { 427 void SessionService::Save() {
457 bool had_commands = !pending_commands().empty(); 428 bool had_commands = !pending_commands().empty();
458 BaseSessionService::Save(); 429 BaseSessionService::Save();
459 if (had_commands) { 430 if (had_commands) {
460 RecordSessionUpdateHistogramData( 431 RecordSessionUpdateHistogramData(
461 chrome::NOTIFICATION_SESSION_SERVICE_SAVED, 432 chrome::NOTIFICATION_SESSION_SERVICE_SAVED,
462 &last_updated_save_time_); 433 &last_updated_save_time_);
463 content::NotificationService::current()->Notify( 434 content::NotificationService::current()->Notify(
464 chrome::NOTIFICATION_SESSION_SERVICE_SAVED, 435 chrome::NOTIFICATION_SESSION_SERVICE_SAVED,
465 content::Source<Profile>(profile()), 436 content::Source<Profile>(profile()),
(...skipping 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after
1534 50); 1505 50);
1535 if (use_long_period) { 1506 if (use_long_period) {
1536 std::string long_name_("SessionRestore.SaveLongPeriod"); 1507 std::string long_name_("SessionRestore.SaveLongPeriod");
1537 UMA_HISTOGRAM_CUSTOM_TIMES(long_name_, 1508 UMA_HISTOGRAM_CUSTOM_TIMES(long_name_,
1538 delta, 1509 delta,
1539 save_delay_in_mins_, 1510 save_delay_in_mins_,
1540 save_delay_in_hrs_, 1511 save_delay_in_hrs_,
1541 50); 1512 50);
1542 } 1513 }
1543 } 1514 }
OLDNEW
« no previous file with comments | « chrome/browser/sessions/session_service.h ('k') | chrome/browser/sessions/session_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698