summaryrefslogtreecommitdiffstats
path: root/chrome/browser/sessions/session_id.cc
blob: 5d3c07572a87baa0f4303f8996a0e3ce0629f6d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/sessions/session_id.h"

#include "chrome/browser/sessions/session_tab_helper.h"

static SessionID::id_type next_id = 1;

SessionID::SessionID() {
  id_ = next_id++;
}

SessionID::id_type SessionID::IdForTab(const content::WebContents* tab) {
  const SessionTabHelper* session_tab_helper =
      tab ? SessionTabHelper::FromWebContents(tab) : NULL;
  return session_tab_helper ? session_tab_helper->session_id().id() : -1;
}

SessionID::id_type SessionID::IdForWindowContainingTab(
    const content::WebContents* tab) {
  const SessionTabHelper* session_tab_helper =
      tab ? SessionTabHelper::FromWebContents(tab) : NULL;
  return session_tab_helper ? session_tab_helper->window_id().id() : -1;
}