Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / chrome / browser / extensions / api / sessions / session_id.h
blob6cdcb5fcd13f4fda339954959e449331d47be3bd
1 // Copyright 2013 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.
5 #ifndef CHROME_BROWSER_EXTENSIONS_API_SESSIONS_SESSION_ID_H__
6 #define CHROME_BROWSER_EXTENSIONS_API_SESSIONS_SESSION_ID_H__
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h"
13 namespace extensions {
15 class SessionId {
16 public:
17 // Returns a SessionId, representing either a local or a foreign session.
18 // In the case that the session is local, |session_tag_| will be empty string.
19 // |session_string| should be in the format that ToString() would produce.
20 static scoped_ptr<SessionId> Parse(const std::string& session_string);
22 // Constructs a SessionId object for the given session information.
23 // |session_tag| is the string used to uniquely identify a synced foreign
24 // session from the SessionModelAssociator. In the case that SessionId
25 // represents a local session, |session_tag_| will be the empty string. |id|
26 // uniquely identifies either a window or tab object in the local or the
27 // |session_tag| session.
28 SessionId(const std::string& session_tag, int id);
30 // Returns true if the SessionId represents a foreign session.
31 bool IsForeign() const;
33 // Returns the compressed std::string representation of a SessionId in the
34 // same format that Parse() accepts as its |session_string| parameter.
35 std::string ToString() const;
37 const std::string& session_tag() const { return session_tag_; }
38 int id() const { return id_; }
40 private:
41 // The unique identifier for a foreign session, given by the
42 // SessionModelAssociator.
43 std::string session_tag_;
45 // ID corresponding to a window or tab object.
46 int id_;
48 DISALLOW_COPY_AND_ASSIGN(SessionId);
51 } // namespace extensions
53 #endif // CHROME_BROWSER_EXTENSIONS_API_SESSIONS_SESSION_ID_H__