Page tree
Skip to end of metadata
Go to start of metadata

bool FB::SimpleStreamHelper::onStreamCompleted ( FB::StreamCompletedEvent evt,
FB::BrowserStream Stream 
)
virtual

Called when the stream finished downloading successfully.

Author
Matthias

Reimplemented from FB::DefaultBrowserStreamHandler.

Definition at line 155 of file SimpleStreamHelper.cpp.

References FB::BrowserStream::getHeaders().

156 {
157  if (!evt->success) {
158  if (callback)
159  callback(false, FB::HeaderMap(), boost::shared_array<uint8_t>(), received);
160  callback.clear();
161  self.reset();
162  return false;
163  }
164  if (!data) {
165  data = boost::shared_array<uint8_t>(new uint8_t[received]);
166  int i = 0;
167  for (BlockList::const_iterator it = blocks.begin();
168  it != blocks.end(); ++it) {
169  size_t offset(i * blockSize);
170  size_t len(received - offset);
171  if (len > blockSize)
172  len = blockSize;
173 
174  std::copy(it->get(), it->get()+len, data.get()+offset);
175  ++i;
176  }
177  // Free all the old blocks
178  blocks.clear();
179  }
180  if (callback && stream) {
181  std::multimap<std::string, std::string> headers;
182  headers = parse_http_headers(stream->getHeaders());
183  callback(true, headers, data, received);
184  }
185  callback.clear();
186  self.reset();
187  return false; // Always return false to make sure the browserhost knows to let go of the object
188 }
BrowserStreamPtr stream
stream instance, don't use yourself

Here is the call graph for this function:

  • No labels