/*
 * Copyright 2011 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
//
// Specification of  protocol buffers that are used to marshall the
// in-memory state of an invalidation client.
//
// Note: unless otherwise specified in a comment, all fields in all messages
// are required, even though they are listed as optional.

syntax = "proto2";

package com.google.protos.ipc.invalidation;

option optimize_for = LITE_RUNTIME;

option java_outer_classname = "JavaClient";


import 'client.proto';
import 'client_protocol.proto';

// State of the batched messages in the ProtocolHandler. Corresponds to
// ProtocolHandler.Batcher.
message BatcherState {
  repeated ObjectIdP registration = 1;
  repeated ObjectIdP unregistration = 2;
  repeated InvalidationP acknowledgement = 3;
  repeated RegistrationSubtree registration_subtree = 4;
  optional InitializeMessage initialize_message = 5;
  optional InfoMessage info_message = 6;
}

// State of the protocol handler. Fields correspond directly to fields in
// ProtocolHandler.java.
message ProtocolHandlerState {
  optional int32 message_id = 1;
  optional int64 last_known_server_time_ms = 2;
  optional int64 next_message_send_time_ms = 3;
  optional BatcherState batcher_state = 4;
}

// State of the registration manager.
message RegistrationManagerStateP {
  repeated ObjectIdP registrations = 1;
  optional RegistrationSummary last_known_server_summary = 2;
  repeated RegistrationP pending_operations = 3;
}

// State of a recurring task. Fields correspond directly to fields in
// RecurringTask.java.
message RecurringTaskState {
  optional int32 initial_delay_ms = 1;
  optional int32 timeout_delay_ms = 2;
  optional bool scheduled = 3;
  optional ExponentialBackoffState backoff_state = 4;
}

// State of the statistics object. Marshalling is done by marshalling the
// SimplePairs returned by Statistics.fillWithNonZeroStatistics into
// PropertyRecords.
message StatisticsState {
  repeated PropertyRecord counter = 1;
}

// State of the invalidation client. Fields correspond directly to fields in
// InvalidationClientImpl.java.
message InvalidationClientState {
  optional RunStateP run_state = 1;
  optional bytes client_token = 2;
  optional bytes nonce = 3;
  optional bool should_send_registrations = 4;
  optional int64 last_message_send_time_ms = 5;
  optional bool is_online = 6;
  optional ProtocolHandlerState protocol_handler_state = 7;
  optional RegistrationManagerStateP registration_manager_state = 8;
  optional RecurringTaskState acquire_token_task_state = 9;
  optional RecurringTaskState reg_sync_heartbeat_task_state = 10;
  optional RecurringTaskState persistent_write_task_state = 11;
  optional RecurringTaskState heartbeat_task_state = 12;
  optional RecurringTaskState batching_task_state = 13;
  optional PersistentTiclState last_written_state = 14;
  optional StatisticsState statistics_state = 15;
}
