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