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

Unified Diff: components/proximity_auth/connection.cc

Issue 562763004: [EasyUnlock] Port PermitMessage class to native code. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Left-shift by zero bits for parallelism Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/proximity_auth/connection.h ('k') | components/proximity_auth/connection_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/proximity_auth/connection.cc
diff --git a/components/proximity_auth/connection.cc b/components/proximity_auth/connection.cc
index 5a35e4dd21f05cf04c9358225ea1abc05fca0274..65f6dd6d74e770bea85c5d0acb0c24c02f755ff3 100644
--- a/components/proximity_auth/connection.cc
+++ b/components/proximity_auth/connection.cc
@@ -77,25 +77,26 @@ void Connection::OnBytesReceived(const std::string& bytes) {
}
received_bytes_ += bytes;
- if (HasReceivedCompleteMessage()) {
- scoped_ptr<WireMessage> message = DeserializeWireMessage();
- if (message) {
- FOR_EACH_OBSERVER(
- ConnectionObserver, observers_, OnMessageReceived(*this, *message));
- }
-
- // Whether the message was parsed successfully or not, clear the
- // |received_bytes_| buffer.
- received_bytes_.clear();
+
+ bool is_incomplete_message;
+ scoped_ptr<WireMessage> message =
+ DeserializeWireMessage(&is_incomplete_message);
+ if (is_incomplete_message)
+ return;
+
+ if (message) {
+ FOR_EACH_OBSERVER(
+ ConnectionObserver, observers_, OnMessageReceived(*this, *message));
}
-}
-bool Connection::HasReceivedCompleteMessage() {
- return WireMessage::IsCompleteMessage(received_bytes_);
+ // Whether the message was parsed successfully or not, clear the
+ // |received_bytes_| buffer.
+ received_bytes_.clear();
}
-scoped_ptr<WireMessage> Connection::DeserializeWireMessage() {
- return WireMessage::Deserialize(received_bytes_);
+scoped_ptr<WireMessage> Connection::DeserializeWireMessage(
+ bool* is_incomplete_message) {
+ return WireMessage::Deserialize(received_bytes_, is_incomplete_message);
}
} // namespace proximity_auth
« no previous file with comments | « components/proximity_auth/connection.h ('k') | components/proximity_auth/connection_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698