Rename files in runtime/base, part 6
[hiphop-php.git] / hphp / runtime / server / rpc_request_handler.h
blob867c8ff1f567218b6b421c8043a716a106c2722e
1 /*
2 +----------------------------------------------------------------------+
3 | HipHop for PHP |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-2013 Facebook, Inc. (http://www.facebook.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
17 #ifndef incl_HPHP_RPC_REQUEST_HANDLER_H_
18 #define incl_HPHP_RPC_REQUEST_HANDLER_H_
20 #include "hphp/runtime/server/server.h"
21 #include "hphp/runtime/base/execution_context.h"
23 namespace HPHP {
25 class SourceRootInfo;
26 class RequestURI;
27 class Transport;
28 DECLARE_BOOST_TYPES(SatelliteServerInfo);
29 ///////////////////////////////////////////////////////////////////////////////
31 class RPCRequestHandler : public RequestHandler {
32 public:
33 enum class ReturnEncodeType {
34 Json = 1,
35 Serialize = 2,
38 RPCRequestHandler(int timeout, bool info);
39 virtual ~RPCRequestHandler();
41 void setServerInfo(SatelliteServerInfoPtr info) { m_serverInfo = info;}
43 // implementing RequestHandler
44 virtual void handleRequest(Transport *transport);
46 /**
47 * Force a reset before the next request.
49 void setReset() { m_reset = true; }
51 time_t getLastResetTime() const { return m_lastReset; }
53 void setReturnEncodeType(ReturnEncodeType et) { m_returnEncodeType = et; }
54 ReturnEncodeType getReturnEncodeType() const { return m_returnEncodeType; }
55 private:
56 ExecutionContext *m_context;
57 SatelliteServerInfoPtr m_serverInfo;
58 int m_requestsSinceReset;
59 bool m_reset;
60 bool m_logResets;
61 ReturnEncodeType m_returnEncodeType;
62 time_t m_lastReset;
64 void initState();
65 void cleanupState();
66 bool needReset() const;
67 bool executePHPFunction(Transport *transport,
68 SourceRootInfo &sourceRootInfo,
69 ReturnEncodeType returnEncodeType);
71 std::string getSourceFilename(const std::string &path,
72 SourceRootInfo &sourceRootInfo);
75 ///////////////////////////////////////////////////////////////////////////////
78 #endif // incl_HPHP_RPC_REQUEST_HANDLER_H_