Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(223)

Side by Side Diff: chrome/browser/local_discovery/privetv3_session.h

Issue 314303009: Comments and style nits. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fri 06/06/2014 11:55:05.73 Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_LOCAL_DISCOVERY_PRIVETV3_SESSION_H_ 5 #ifndef CHROME_BROWSER_LOCAL_DISCOVERY_PRIVETV3_SESSION_H_
6 #define CHROME_BROWSER_LOCAL_DISCOVERY_PRIVETV3_SESSION_H_ 6 #define CHROME_BROWSER_LOCAL_DISCOVERY_PRIVETV3_SESSION_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback.h" 10 #include "base/callback.h"
11 #include "base/memory/scoped_ptr.h" 11 #include "base/memory/scoped_ptr.h"
12 #include "base/values.h" 12
13 namespace base {
14 class DictionaryValue;
15 }
13 16
14 namespace local_discovery { 17 namespace local_discovery {
15 18
16 class PrivetHTTPClient; 19 class PrivetHTTPClient;
17 20
21 // Manages secure communication between browser and local Privet device.
18 class PrivetV3Session { 22 class PrivetV3Session {
19 public: 23 public:
20 typedef base::Callback< 24 typedef base::Callback<
21 void(bool success, const base::DictionaryValue& response)> 25 void(bool success, const base::DictionaryValue& response)>
22 RequestCallback; 26 RequestCallback;
23 27
28 // Delegate to be implemented by client code.
24 class Delegate { 29 class Delegate {
25 public: 30 public:
26 typedef base::Callback<void(bool confirm)> ConfirmationCallback; 31 typedef base::Callback<void(bool confirm)> ConfirmationCallback;
27 32
28 virtual ~Delegate() {} 33 virtual ~Delegate();
29 34
35 // Called when client code should prompt user to check |confirmation_code|.
30 virtual void OnSetupConfirmationNeeded( 36 virtual void OnSetupConfirmationNeeded(
31 const std::string& confirmation_code, 37 const std::string& confirmation_code,
32 const ConfirmationCallback& callback) = 0; 38 const ConfirmationCallback& callback) = 0;
33 39
40 // Called when session successfully establish and client code my call
41 // |CreateRequest| method.
34 virtual void OnSessionEstablished() = 0; 42 virtual void OnSessionEstablished() = 0;
35 43
44 // Called when session setup fails.
36 virtual void OnCannotEstablishSession() = 0; 45 virtual void OnCannotEstablishSession() = 0;
37 }; 46 };
38 47
48 // Represents request in progress using secure session.
39 class Request { 49 class Request {
40 public: 50 public:
41 virtual ~Request() {} 51 virtual ~Request();
42
43 virtual void Start() = 0; 52 virtual void Start() = 0;
44 }; 53 };
45 54
46 virtual ~PrivetV3Session() {} 55 PrivetV3Session(scoped_ptr<PrivetHTTPClient> client, Delegate* delegate);
56 ~PrivetV3Session();
47 57
48 static scoped_ptr<PrivetV3Session> Create(PrivetHTTPClient* client); 58 // Establishes a session, will call |OnSetupConfirmationNeeded| and then
59 // |OnSessionEstablished|.
60 void Start();
49 61
50 // Establish a session, will call |OnSetupConfirmationNeeded| and then 62 // Create a single /privet/v3/session/call request.
51 // |OnSessionEstablished|. 63 // Must be called only after receiving |OnSessionEstablished|.
52 virtual void Start() = 0; 64 scoped_ptr<Request> CreateRequest(const std::string& api_name,
65 const base::DictionaryValue& request,
66 const RequestCallback& callback);
53 67
54 // Create a single /privet/v2/session/call request. 68 private:
55 virtual scoped_ptr<Request> CreateRequest( 69 DISALLOW_COPY_AND_ASSIGN(PrivetV3Session);
56 const char* api_name,
57 const base::DictionaryValue& request,
58 const RequestCallback& callback);
59 }; 70 };
60 71
61 } // namespace local_discovery 72 } // namespace local_discovery
62 73
63 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_PRIVETV3_SESSION_H_ 74 #endif // CHROME_BROWSER_LOCAL_DISCOVERY_PRIVETV3_SESSION_H_
OLDNEW
« no previous file with comments | « chrome/browser/local_discovery/privet_http_asynchronous_factory.h ('k') | chrome/browser/local_discovery/privetv3_session.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698