Answer by Professional Japanese Teacher
“ごちそうさまGochisoosama” is an expression often said at the end of a meal to thank the host for his hospitality.
The actual expression is “ごちそうさまでしたGochisoosamadeshita” and you can shorten it to “ごちそうさまGochisoosama”. For example, if you are having a meal at a friend’s house, after the meal, you can say “ごちそうさまでしたGochisoosamadeshita” to thank him.
If you are at a restaurant, you say this expression to express your appreciation and thank the staff for serving you. Sometimes, people also say “ごちそうさまGochisoosama” when they prepare and eat their own meals.
It sounds a bit weird to English speakers to “thank” yourself for the meal, but to the Japanese, it shows appreciation to the food and meal that you have partaken, regardless of whether it was prepared by yourself or by others.