| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_SESSIONS_SESSION_ID_H_ | |
| 6 #define CHROME_BROWSER_SESSIONS_SESSION_ID_H_ | |
| 7 | |
| 8 #include "base/basictypes.h" | |
| 9 | |
| 10 namespace content { | |
| 11 class WebContents; | |
| 12 } | |
| 13 | |
| 14 // Uniquely identifies a tab or window for the duration of a session. | |
| 15 class SessionID { | |
| 16 public: | |
| 17 typedef int32 id_type; | |
| 18 | |
| 19 SessionID(); | |
| 20 ~SessionID() {} | |
| 21 | |
| 22 // If the specified WebContents has a SessionTabHelper (probably because it | |
| 23 // was used as the contents of a tab), returns a tab id. This value is | |
| 24 // immutable for a given tab. It will be unique across Chrome within the | |
| 25 // current session, but may be re-used across sessions. Returns -1 | |
| 26 // for a NULL WebContents or if the WebContents has no SessionTabHelper. | |
| 27 static id_type IdForTab(const content::WebContents* tab); | |
| 28 | |
| 29 // If the specified WebContents has a SessionTabHelper (probably because it | |
| 30 // was used as the contents of a tab), and has ever been attached to a Browser | |
| 31 // window, returns Browser::session_id().id() for that Browser. If the tab is | |
| 32 // being dragged between Browser windows, returns the old window's id value. | |
| 33 // If the WebContents has a SessionTabHelper but has never been attached to a | |
| 34 // Browser window, returns an id value that is different from that of any | |
| 35 // Browser. Returns -1 for a NULL WebContents or if the WebContents has no | |
| 36 // SessionTabHelper. | |
| 37 static id_type IdForWindowContainingTab(const content::WebContents* tab); | |
| 38 | |
| 39 // Returns the underlying id. | |
| 40 void set_id(id_type id) { id_ = id; } | |
| 41 id_type id() const { return id_; } | |
| 42 | |
| 43 private: | |
| 44 id_type id_; | |
| 45 }; | |
| 46 | |
| 47 #endif // CHROME_BROWSER_SESSIONS_SESSION_ID_H_ | |
| OLD | NEW |