session.cpp
910 Bytes
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include "stdafx.h"
#include "etradeclient/browser/session.h"
#include "include/wrapper/cef_helpers.h"
Session::Session() : m_expried(true) /*The initial state should be 'expired'.*/
{}
Session& Session::Instance()
{
static Session session_manager;
return session_manager;
}
void Session::OnExpired()
{
std::lock_guard<std::mutex> lg(m_mtx);
CEF_REQUIRE_IO_THREAD();
m_cookies.clear();
m_expried = true;
}
void Session::OnValid()
{
std::lock_guard<std::mutex> lg(m_mtx);
m_expried = false;
}
bool Session::IsExpired()
{
std::lock_guard<std::mutex> lg(m_mtx);
return m_expried;
}
void Session::SetCookies(const CookiesT& cookies)
{
m_cookies = cookies;
}
const Session::CookiesT& Session::Cookies() const
{
return m_cookies;
}
void Session::SetUserName(const std::wstring& user_name)
{
m_user_name = user_name;
}
const std::wstring& Session::UserName() const
{
return m_user_name;
}