FireBreath  1.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Pages
static FB::HttpStreamResponsePtr FB::SimpleStreamHelper::SynchronousRequest ( const FB::BrowserHostPtr host,
const BrowserStreamRequest req 
)
static

Do not call from the main thread! Starts a Synchronous HTTP request.

Parameters
hostconst FB::BrowserHostPtr & BrowserHost to use (m_host on the plugin object)
reqconst BrowserStreamRequest & BrowserStreamRequest describing the request to make; should not have a callback or eventsink
Author
taxilian
Since
1.7

Definition at line 109 of file SimpleStreamHelper.cpp.

References FB::BrowserStreamRequest::setCallback().

110 {
111  // We can't ever block on the main thread, so SynchronousGet can't be called from there.
112  // Also, if you could block the main thread, that still wouldn't work because the request
113  // is processed on the main thread!
114  assert(!host->isMainThread());
115  SyncHTTPHelper helper;
116  try {
117  FB::HttpCallback cb(boost::bind(&SyncHTTPHelper::getURLCallback, &helper, _1, _2, _3, _4));
118  FB::BrowserStreamRequest req2(req);
119  req2.setCallback(cb);
120  FB::SimpleStreamHelperPtr ptr = AsyncRequest(host, req2);
121  helper.setPtr(ptr);
122  helper.waitForDone();
123  } catch (const std::exception&) {
124  // If anything weird happens, just return NULL (to indicate failure)
125  return FB::HttpStreamResponsePtr();
126  }
127  return helper.m_response;
128 }
static FB::SimpleStreamHelperPtr AsyncRequest(const BrowserHostConstPtr &host, const BrowserStreamRequest &req)
Creates an asynchronous HTTP request from the provided BrowserStreamRequest.
Information about an HTTP request to be made.

Here is the call graph for this function: