Recent advances in energy-harvesting (EH) technology have enabled the realization of wireless systems composed of rechargeable devices. In this paper, we analyze the problem of maximizing the data transmission for the point-to-point (P2P) wireless communication systems which the transmitter is able to harvest energy from ambient environment. To be more general, we consider the EH optimal problem under the quasi-static frequency-selective fading channel. Our optimization work also includes energy storage loss constraint of the battery; therefore, we apply an efficient harvesting architecture, i.e., harvest-use-store (HUS), where the harvested energy is prioritized for use in data transmission. To balance the energy stored in or extracted from the battery for maximization throughput with the randomly arrival harvesting energy constraint, we first characterize the amazing properties of our optimal policy, implying a double-threshold structure of the solution, then investigate a dynamic programming (DP)-based double-layer optimal allocation policy. Further, we tend to analyze the online solution. First, the optimal policy is provided by using the continuous time stochastic dynamic programming. Then, building on the intuition from the optimal offline policy (i.e., double-threshold structure), a heuristic online policy is proposed, which is simple to be implemented. Numerical results are presented to validate the theoretical analysis and to demonstrate the superior performance over the existing counterparts in the previous literatures and show that the proposed online policies track well to the optimal solution.